[PATCH 01/10] Use void as "parameter" for functions without arguments.

Simon Ruderich simon at ruderich.org
Wed Feb 5 14:49:57 CET 2014


On Tue, Feb 04, 2014 at 08:17:05AM +0100, Thorsten Wißmann wrote:
>   - I'm too lazy to continue writing void everywhere.
>   - It looks totally ugly...
>   - I don't see how ignoring that and writing ambigous fkt() causes any
>     issues regarding security or stability. One will notice it if
>     parameters to a function are ignored.

But one might not immediately notice missing parameters to a
function, i.e. the caller forgot an argument.

>>  // core functions
>> -int quit() {
>> +int quit(int argc, char* argv[]) {
>>      g_aboutToQuit = true;
>>      return 0;
>>  }
>
> I really prefer the previous version, because in the other case there
> are parameters of that function which aren't used. Same for reload,
> true, false, etc.

But a reader immediately knows that the function takes arguments
which are at the moment unused. I find that clearer.

> Is there any advantage of writing (void), except that it is more
> "conform"?

See above. It's not a big advantage, but it's clearer and can
prevent problems in the future. And to me the void doesn't look
too bad, but that's a matter of opinion of course.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://listi.jpberlin.de/pipermail/hlwm/attachments/20140205/0d728643/attachment.asc>


More information about the hlwm mailing list