[PATCH v2 2/3] libio: Update tst-fmemopen2.c
Rasmus Villemoes
rv@rasmusvillemoes.dk
Sat Jun 28 23:57:00 GMT 2014
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
More information about the Libc-alpha
mailing list