PERFORCE change 123376 for review

Shteryana Shopova syrinx at FreeBSD.org
Fri Jul 13 07:24:39 UTC 2007


style(9) says:
<quote>Many of the style rules are implicit in the examples.</quote> ;)

IMO it is a good idea to try to keep to the rules while coding. Also
all code lines should (must ;)) contain 80 characters max.

cheers,
Shteryana

On 7/13/07, Kostik Belousov <kostikbel at gmail.com> wrote:
> On Fri, Jul 13, 2007 at 12:40:38PM +1100, 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:
> > Ok, I'll make lines shorter.
> > I've not found strict rule in style(9) for ");" at the end of multiple lines
> > of parameters in function call, and thought my variant is more simple for
> > reading. Same intention is in using curly brackets in complex single
> > statement in if-else block. Well, it's not big problem, I may correct this
> > on next submits.
> >
> > >And, don't use "sprintf". Use "snprintf" instead.
> > As for snprintf(), I'm also wanted to make it safer, but according to man
> > and header file - libstand have no such function. Same for strnstr().
> > I'm thinking about skipping sprintf() with many parameters while generating
> > header and writing directly to socket, in such case will be more function
> > calls and checks, but only  one of them (Range field, that always has
> > predictable size smaller then default buffer size) will use sprintf().
> Nobody will object if you add the functions to libstand.
>
>


More information about the p4-projects mailing list