This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] [BZ #12836] Make fmemopen(buf,size,"w+b") binary.


>  	* libio/Makefile (tests): Updated.
>  	* libio/test-fmemopen-bz12836.c: New file.

Write it like this:

 	* libio/test-fmemopen-bz12836.c: New file.
 	* libio/Makefile (tests): Add it.

>  tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
> -	tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \
> +	tst_wprintf2 tst-widetext test-fmemopen test-fmemopen-bz12836 tst-ext tst-ext2 \

This makes the line too long.

> --- a/libio/fmemopen.c
> +++ b/libio/fmemopen.c
> @@ -201,6 +201,7 @@ fmemopen (void *buf, size_t len, const char *mode)
>  {
>    cookie_io_functions_t iof;
>    fmemopen_cookie_t *c;
> +  int i;

Use C99-style 'for (int i = ...'.

> +  for (i = 0; mode[i]; i++)

No implicit Boolean coercion!  "mode[i] != '\0'"

> +static char buffer[] = "foobar";
> +static char s[]      = "abc";

Put these inside the function.
Don't use extra spaces to align the = like that.

> +  stream = fmemopen (buffer, strlen (buffer), "w+b");

Use sizeof on constant arrays.

> +	fprintf (stream, s);
> +  fclose (stream);

Indentation wrong here.

> +	for (i = 0 ; i < strlen (s) ; i++)

Use sizeof.  No spaces before ;.

> +        printf ("Disagree at position %i.\n",i);

Space after comma.

> +  if (buffer[strlen (s)] == '\0')

Use sizeof.

> +      printf ("Not opened in binary mode.\n");

Use puts.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]