[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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

Attachment: pgplqUyXEKp7W.pgp
Description: PGP signature