The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,473 other followers

Archive for 2019

Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been initialized”…

Posted by jpluimers on 2019/01/21

Historically, [WayBack] W1036: Variable '%s' might not have been initialized (Delphi) has had a lot of gotchas.

The most important still is that it never show for managed types (strings, interfaces, etc).

Usually W1036 shows for non-managed types, but Dan Hacker has found a new case where it does not in [WayBack] Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been initialized’ if the StringsToDo parameter in DoSomething is defined as a var… – Dan Hacker – Google+

He noticed it in Delphi XE and 10.2 Tokyo.

I tested it with the Win32 compiler in XE8.

This warns:

program W1036;
{$APPTYPE CONSOLE}
uses
  System.SysUtils,
  System.Classes;

procedure DoSomething(var StringsToDo: TStringList); // <-------- this line makes the difference
begin
  //do nothing
end;

procedure Test;
var
  MyStrings : TStringList;
begin
  MyStrings.Free;   {W1036 warning if StringsToDo param is NOT var}
  DoSomething(MyStrings);
end;

begin
end.

This does not warn:

program W1036;
{$APPTYPE CONSOLE}
uses
  System.SysUtils,
  System.Classes;

procedure DoSomething(StringsToDo: TStringList); // <-------- this line makes the difference
begin
  //do nothing
end;

procedure Test;
var
  MyStrings : TStringList;
begin
  MyStrings.Free;   {W1036 warning if StringsToDo param is NOT var}
  DoSomething(MyStrings);
end;

begin
end.

initially, I misread his report and reacted wrongly on the cause (but rightly on the suggested use case of var and of TStringList):

Because a var parameter means that the caller should pass in an initialised parameter. Otherwise it should be an out parameter, not a var parameter.

var parameter for reference types like TStrings (only pass as TStringList if it deliberately is not compatible with TStrings) is a risky thing anyway, because the called method can overwrite it and then the caller has to notice the change, then decide what to do with the previous value (likely free it).

I later correct myself:

Looking better, I think it is a compiler issue.

The only difference between nothing and var is the loading of the parameter as a pointer:

with var

//W1036.dpr.16: MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
//004CD924 8B45FC mov eax,[ebp-$04]
//004CD927 E8B8A6F3FF call TObject.Free
//Project1.dpr.17: DoSomething(MyStrings);
//004CD92C 8D45FC lea eax,[ebp-$04]
//004CD92F E8E0FFFFFF call DoSomething
without var
//W1036.dpr.16: MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
//004CD924 8B45FC mov eax,[ebp-$04]
//004CD927 E8B8A6F3FF call TObject.Free
//Project1.dpr.17: DoSomething(MyStrings);
//004CD92C 8B45FC mov eax,[ebp-$04]
//004CD92F E8E0FFFFFF call DoSomething

So:

  • with a var, a pointer to the instance of MyStrings (obtained by a lea instruction) gets pushed on the stack
  • without a var, the instance of MyStrings (obtained by a mov instruction) gets pushed on the stack.

For the difference metween mov and lea, and the use of [] brackets, see:

–jeroen

Source: Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been i…

Posted in Delphi, Development, Software Development | Leave a Comment »

Linus Torvalds – Google+: Working gadgets: Ubiquiti UniFi collection (and a whole bunch of Unifi/Ubiquiti/Ubtn links).

Posted by jpluimers on 2019/01/21

Seems my interest in Ubiquiti needs more research: [WayBackLinus Torvalds – Google+: Working gadgets: Ubiquiti UniFi collection.

Hopefully by now I’ve time to re-design the WiFi coverage in the house and invest in a few of those access points.

Related:

Splitting 5Ghz and 2.4Ghz SSIDs: two ways (I think the second is cleaner)

  1. Either have one WLAN group with a set of SSIDs, then in each access point disable the 2.4Ghz SSID on the 5GHz radio, and disable the 5Ghz SSID on the 2.4Ghz radio
  2. Have different WLAN groups with an SSID (or set of SSIDs) for each frequency, then in each access point select the appropriate group for each radio

For both the first and second one, you need to configure under “Config” -> “WLANs”.

For the second one, you can clone from the first, then change the SSID names.

–jeroen

Read the rest of this entry »

Posted in Power User, Ubiquiti, WiFi | Leave a Comment »

Installing as a LAN -> WiFi bridge: FRITZ!WLAN Repeater 1750E

Posted by jpluimers on 2019/01/21

I have a bunch of [WayBackFRITZ!WLAN Repeater 1750E | Overview | AVM International devices; this is the quickest way to install them as LAN -> WiFi bridge (connect ethernet to your LAN; use the WiFi as a bridge).

  1. Connect the FRITZ!WLAN to your LAN
  2. Connect the FRITZ!WLAN to power
  3. Connect your laptop to the WiFi SSID FRITZ!WLAN Repeater 1750E with password 00000000 (that eight times a zero)
  4. Set your laptop with a fixed IP address 192.168.178.127 with netmask 255.255.255.0 and gateway 192.168.178.2 for WiFi.
  5. Connect to your FRITZ!WLAN at http://192.168.178.2
  6. Setup your FRITZ!WLAN for the first time (password, country) and have it reboot
  7. Logon to the FRITZ!WLAN
  8. Change the WiFI password and the SSID for 2.4 Ghz and 5.0 Ghz channels (I use a different SSID for both as many Fritz!Box devices have both bad 2.4Ghz performance and a hard time to automatically switch from 2.4Ghz to 5.0Ghz on the same SSID automagically).
  9. Change your laptop to use DHCP on WiFi
  10. Reconnect to the Fritz!Box with the new SSID and password

–jeroen

Posted in Fritz!, Fritz!WLAN, Internet, Power User | Leave a Comment »

Google Sheet with forwarding addresses. Please feel free to add yours….

Posted by jpluimers on 2019/01/21

[WayBack] I have created a Google Sheet with forwarding addresses. Please feel free to add yours- only the info you are comfortable with. Please DO NOT add full e… – Di Cleverly – Google+

[Archive.is] Forwarding Addresses – Google Sheets

–jeroen

Posted in G+: GooglePlus, LifeHacker, Power User, SocialMedia | Leave a Comment »

National Cyber Security Centre publish Ubuntu 18.04 LTS Security Guide | Ubuntu blog

Posted by jpluimers on 2019/01/18

For my link archive: [WayBack] National Cyber Security Centre publish Ubuntu 18.04 LTS Security Guide | Ubuntu blog

Via: [WayBack] A new best practice guide for hardening #Ubuntu Desktop 18.04 from the National Cyber Security Centre (part of UK gov): https://blog.ubuntu.com/2018/07… – Will Cooke – Google+

–jeroen

Posted in *nix, Linux, Power User, Ubuntu | Leave a Comment »

 
%d bloggers like this: