PERFORCE change 123376 for review

Hans Petter Selasky hselasky at c2i.net
Thu Jul 12 16:31:27 UTC 2007


On Thursday 12 July 2007 18:17, Constantine A. Murenin wrote:
> On 12/07/2007 10:28, Alexey Tarasov wrote:
> > http://perforce.freebsd.org/chv.cgi?CH=123376
> >
> > Change 123376 by taleks at taleks_th on 2007/07/12 14:27:18
>
> ...
>
> > @@ -104,11 +107,11 @@
> >  	}
> >
> >  	if ( (from == 0) && (size == 0) ) {
> > -		sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nConnection:
> > Close\r\n\r\n", +		sprintf(http_data, "GET /%s HTTP/1.1\r\nHost:
> > %s\r\nConnection: Close\r\nUser-Agent: pxe_http/0\r\n\r\n", filename,
> > server_name
> >  		);
> >  	} else {
> > -		sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nRange:
> > %d-%d\r\nConnection: Close\r\n\r\n", +		sprintf(http_data, "GET /%s
> > HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-%d\r\nConnection:
> > Close\r\nUser-Agent: pxe_http/0\r\n\r\n", filename, server_name, from,
> > from + size
> >  		);
> >  	}
>
> You might want to change long lines like these to something as follows:
>
> 	if ( (from == 0) && (size == 0) )
> 		sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\n"
> 		    "Connection: Close\r\nUser-Agent: pxe_http/0\r\n\r\n",
> 		    filename, server_name);
> 	else
> 		sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\n"
> 		    "Range: bytes=%d-%d\r\n"
> 		    "Connection: Close\r\nUser-Agent: pxe_http/0\r\n\r\n",
> 		    filename, server_name, from, from + size);
>
> Also note that ");" should not appear on a line by itself, if I'm reading
> style(9) correctly.
>
> Removing curly brackets is optional in this case, because lines are
> somewhat long, but personally, I do like them removed, too. :)
>

And, don't use "sprintf". Use "snprintf" instead.

--HPS


More information about the p4-projects mailing list