Re: [PATCH 3/5] logger: optimize string initializations

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

 



On Sun, Aug 10, 2014 at 12:56:09PM +0100, Sami Kerola wrote:
> -	char pid[32] = { '\0' }, time[64] = { '\0' }, timeq[80] = { '\0' };
> +	char pid[32], time[64], timeq[80];

 I agree that the original code is not elegant, but "else foo[0] =
 '\0'" is also pretty ugly. It would be better to set all to the
 default by one line

   *pid = *time = *timeq = '\0';

 at begin of the function.


>  	if ((process = get_process_id(ctl)))
>  		snprintf(pid, sizeof(pid), " %d", process);
> +	else
> +		pid[0] = '\0';

 I really don't like hairy code like this.

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux