This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 2/3] libio: Update tst-fmemopen2.c
- From: Rasmus Villemoes <rv at rasmusvillemoes dot dk>
- To: libc-alpha at sourceware dot org
- Date: Sun, 29 Jun 2014 01:57:29 +0200
- Subject: Re: [PATCH v2 2/3] libio: Update tst-fmemopen2.c
- Authentication-results: sourceware.org; auth=none
- References: <53AD653D dot 8070504 at linux dot vnet dot ibm dot com>
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