dhcpcd-discuss

Re: Minor variable scope problem in hook scripts

Roy Marples

Fri Jul 12 15:27:13 2019

On 12/07/2019 16:14, feedback@xxxxxxxxxxxxx wrote:
Small side note:
Theoretically there is still an alternative by unsetting every 'local' variable at the end of each function before returning, but that becomes quite ugly if there are multiple return's. So every function would either be (re-)written in a compatible way or another way would be to unset each variable as early as possible if they are not needed anymore in that function, that could maybe reduce the ugliness even in case of multiple return's.

That's just ugly IMHO. I prefer setting to blank before use.
It's the same as memset(x, 0, sizeof(*x)); before using it.

I'll try and do a thorough audit of the scripts for this over the weekend. But I'm round at my mother in law's, so that might not happen....

Roy

References:
Minor variable scope problem in hook scriptsfeedback
Re: Minor variable scope problem in hook scriptsRoy Marples
Re: Minor variable scope problem in hook scriptsfeedback
Archive administrator: postmaster@marples.name