[PATCH 07/10] command: Replace incorrect use of LENGTH().

Thorsten Wißmann edu at thorsten-wissmann.de
Tue Feb 4 13:52:30 CET 2014


Hi,

On Sat, Feb 01, 2014 at 09:56:42PM +0100, Simon Ruderich wrote:
> LENGTH() has no negative effects because sizeof(char) == 1, but sizeof()
> makes the intention clear.
>
> -    snprintf(buf, LENGTH(buf), "0x%lx", client->window);
> +    snprintf(buf, sizeof(buf), "0x%lx", client->window);

I mean both is right, but the question is what this parameter means.
E.g. in wchar versions it seems this is the length of the buffer and not
the total size in bytes of the underlying data structure, of course they
coincide in the case of ordinary chars.

I personally find LENGTH more readable because it is really the length
of the array, while sizeof gives it's total size.

So I would not agree that sizeof makes the intention clear.

Cheers,
Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/hlwm/attachments/20140204/cf9712c8/attachment.sig>


More information about the hlwm mailing list