Re: [PATCH] progress.c: avoid use of dynamic-sized array

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

 



Boyd Lynn Gerber, Sun, Jun 08, 2008 17:26:15 +0200:
>  		/* Force the last update */
> -		char buf[strlen(msg) + 5];
> +		char buf[128], *bufp;
> +		size_t len = strlen(msg) + 5;
>  		struct throughput *tp = progress->throughput;
> +
> +		bufp = (len < sizeof(buf)) ? buf : xmalloc(len + 1);

It is just a temporary buffer, there is no urgent need to
micro-optimize the allocation like that. Maybe just leave
one of the buffers, the one on stack? It is just a progress
message, snprintf will cut it, yes, but it is unlikely to
cause any harm (unless you forget to \n-terminate it).

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux