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 v2 2/3] libio: Update tst-fmemopen2.c


Adhemerval Zanella <azanella@linux.vnet.ibm.com> writes:

> +  r = 0;
> +  if (fflush (fp) != EOF)
> +    {
> +      printf ("%s: fflush did not return EOF\n", __FUNCTION__);
> +      fclose (fp);
> +      return 1;
> +    }
> +  if (errno != ENOSPC)
> +    {
> +      printf ("%s: errno != ENOSPC\n", __FUNCTION__);
> +      fclose (fp);
> +      return 1;
> +    }
> +

Maybe it would make debugging easier if you printed the value of errno,
e.g. "%s: errno = %d != ENOSPC", and making sure to set it to 0 before
fflush(), so that one can see if errno is even set. Is there a way to
convert errno values to strings representing the symbolic tokens?

> +  fclose (fp);
> +
> +  if (strcmp (buf, "") != 0)

Don't you need to compare to the original contents of buf, i.e. "testing
buffer"? I don't suppose even a '\0' should be written when fmemopen()
is told that it can write to 0 bytes.

> +    {
> +      printf ("%s: strcmp (%s, "") failed\n", __FUNCTION__, buf);

Missing escapes of those inner quotes (I suppose).

Rasmus




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