Debian Bug report logs - #665780
{fread,fwrite}.3: The return value can be the number of characters

version graph

Package: manpages-dev; Maintainer for manpages-dev is Martin Schulze <joey@debian.org>; Source for manpages-dev is src:manpages.

Reported by: Regid Ichira <regid23@yahoo.com>

Date: Mon, 26 Mar 2012 01:57:01 UTC

Severity: normal

Tags: fixed-upstream, patch

Found in version manpages/3.35-0.1

Fixed in version manpages/3.40-0.1

Done: Simon Paillard <spaillard@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Martin Schulze <joey@debian.org>:
Bug#665780; Package manpages-dev. (Mon, 26 Mar 2012 01:57:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Regid Ichira <regid23@yahoo.com>:
New Bug report received and forwarded. Copy sent to Martin Schulze <joey@debian.org>. (Mon, 26 Mar 2012 01:57:04 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Regid Ichira <regid23@yahoo.com>
To: submit@bugs.debian.org
Subject: {fread,fwrite}.3: The return value can be the number of characters
Date: Sun, 25 Mar 2012 18:54:40 -0700 (PDT)
Package:  manpages-dev
Version:  3.35-0.1
Severity: normal
Tags:     patch
File:     /usr/share/man/man3/fread.3.gz

1. The return value is the number of characters in one case.
2. Doesn't the request to continue the fread synopsis line makes it
   longer then 80 characters?

--- a/fread.3   2012-03-26 03:26:43.677236481 +0200
+++ b/fread.3   2012-03-26 03:26:08.000000000 +0200
@@ -47,8 +47,8 @@ fread, fwrite \- binary stream input/out
 .nf
 .B #include <stdio.h>
 .sp
-.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb \
-", FILE *" stream );
+.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb ",
+.BI "             FILE *" stream );
 .sp
 .BI "size_t fwrite(const void *" ptr ", size_t " size ", size_t " nmemb ,
 .BI "              FILE *" stream );
@@ -82,10 +82,11 @@ For nonlocking counterparts, see
 .BR fread ()
 and
 .BR fwrite ()
-return the number of items successfully read or written (i.e., not the
-number of characters).
-If an error occurs, or the end-of-file is
-reached, the return value is a short item count (or zero).
+return the number of items successfully read or written. This number
+equal the number of bytes only when
+.I size
+is 1. It might be less then the requested count (or zero) if an
+error occurs, or the end-of-file is reached.
 .PP
 .BR fread ()
 does not distinguish between end-of-file and error, and callers must use





Information forwarded to debian-bugs-dist@lists.debian.org, Martin Schulze <joey@debian.org>:
Bug#665780; Package manpages-dev. (Mon, 26 Mar 2012 07:03:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to mtk.manpages@gmail.com:
Extra info received and forwarded to list. Copy sent to Martin Schulze <joey@debian.org>. (Mon, 26 Mar 2012 07:03:03 GMT) Full text and rfc822 format available.

Message #10 received at 665780@bugs.debian.org (full text, mbox):

From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Regid Ichira <regid23@yahoo.com>, 665780@bugs.debian.org
Subject: Re: Bug#665780: {fread,fwrite}.3: The return value can be the number of characters
Date: Mon, 26 Mar 2012 19:58:25 +1300
This patch makes no sense to me. How could this information be useful?
I can see no reason to take this patch upstream.

On Mon, Mar 26, 2012 at 2:54 PM, Regid Ichira <regid23@yahoo.com> wrote:
> Package:  manpages-dev
> Version:  3.35-0.1
> Severity: normal
> Tags:     patch
> File:     /usr/share/man/man3/fread.3.gz
>
> 1. The return value is the number of characters in one case.
> 2. Doesn't the request to continue the fread synopsis line makes it
>   longer then 80 characters?
>
> --- a/fread.3   2012-03-26 03:26:43.677236481 +0200
> +++ b/fread.3   2012-03-26 03:26:08.000000000 +0200
> @@ -47,8 +47,8 @@ fread, fwrite \- binary stream input/out
>  .nf
>  .B #include <stdio.h>
>  .sp
> -.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb \
> -", FILE *" stream );
> +.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb ",
> +.BI "             FILE *" stream );
>  .sp
>  .BI "size_t fwrite(const void *" ptr ", size_t " size ", size_t " nmemb ,
>  .BI "              FILE *" stream );
> @@ -82,10 +82,11 @@ For nonlocking counterparts, see
>  .BR fread ()
>  and
>  .BR fwrite ()
> -return the number of items successfully read or written (i.e., not the
> -number of characters).
> -If an error occurs, or the end-of-file is
> -reached, the return value is a short item count (or zero).
> +return the number of items successfully read or written. This number
> +equal the number of bytes only when
> +.I size
> +is 1. It might be less then the requested count (or zero) if an
> +error occurs, or the end-of-file is reached.
>  .PP
>  .BR fread ()
>  does not distinguish between end-of-file and error, and callers must use
>
>
>
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/




Information forwarded to debian-bugs-dist@lists.debian.org, Martin Schulze <joey@debian.org>:
Bug#665780; Package manpages-dev. (Mon, 26 Mar 2012 11:33:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Regid Ichira <regid23@yahoo.com>:
Extra info received and forwarded to list. Copy sent to Martin Schulze <joey@debian.org>. (Mon, 26 Mar 2012 11:33:08 GMT) Full text and rfc822 format available.

Message #15 received at 665780@bugs.debian.org (full text, mbox):

From: Regid Ichira <regid23@yahoo.com>
To: mtk.manpages@gmail.com
Cc: 665780@bugs.debian.org
Subject: Re: Bug#665780: {fread,fwrite}.3: The return value can be the number of characters
Date: Mon, 26 Mar 2012 04:31:59 -0700 (PDT)
--- On Mon, 3/26/12, Michael Kerrisk (man-pages) <mtk.manpages@gmail.com> wrote:

> This patch makes no sense to me. 

  Why not?  Won't

    char c[10];
    fwrite(c, sizeof(char), sizeof(c), stream);

be writing 10 bytes, and returns 10?  I think the intention of the composer
of the page was to emphasize that the number of items returned is not
necessarily the number of bytes.

> How could this information be useful?

  1. It is an accurate description.
  2. The current phrasing is more confusing for beginners.

  I also slightly rephrased it:
--- a/fread.3   2012-03-26 13:03:11.542825729 +0200
+++ b/fread.3   2012-03-26 12:58:04.000000000 +0200
@@ -47,8 +47,8 @@ fread, fwrite \- binary stream input/out
 .nf
 .B #include <stdio.h>
 .sp
-.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb \
-", FILE *" stream );
+.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb ",
+.BI "             FILE *" stream );
 .sp
 .BI "size_t fwrite(const void *" ptr ", size_t " size ", size_t " nmem
b ,
 .BI "              FILE *" stream );
@@ -82,10 +82,12 @@ For nonlocking counterparts, see
 .BR fread ()
 and
 .BR fwrite ()
-return the number of items successfully read or written (i.e., not the
-number of characters).
-If an error occurs, or the end-of-file is
-reached, the return value is a short item count (or zero).
+return the number of items successfully read or written. This number
+equal the number of 8 bit characters only when
+.I size
+is 1. It can be less then
+.I nmemb
+(or zero) if an error occurs, or the end-of-file is reached.
 .PP
 .BR fread ()
 does not distinguish between end-of-file and error, and callers must u
se





Information forwarded to debian-bugs-dist@lists.debian.org, Martin Schulze <joey@debian.org>:
Bug#665780; Package manpages-dev. (Thu, 29 Mar 2012 19:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to mtk.manpages@gmail.com:
Extra info received and forwarded to list. Copy sent to Martin Schulze <joey@debian.org>. (Thu, 29 Mar 2012 19:00:03 GMT) Full text and rfc822 format available.

Message #20 received at 665780@bugs.debian.org (full text, mbox):

From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Regid Ichira <regid23@yahoo.com>
Cc: 665780@bugs.debian.org, control@bugs.debian.org
Subject: Re: Bug#665780: {fread,fwrite}.3: The return value can be the number of characters
Date: Fri, 30 Mar 2012 07:57:33 +1300
tags 665780 fixed-upstream
thanks

Hello Regid,

On Tue, Mar 27, 2012 at 12:31 AM, Regid Ichira <regid23@yahoo.com> wrote:
> --- On Mon, 3/26/12, Michael Kerrisk (man-pages) <mtk.manpages@gmail.com> wrote:
>
>> This patch makes no sense to me.
>
>  Why not?  Won't
>
>    char c[10];
>    fwrite(c, sizeof(char), sizeof(c), stream);
>
> be writing 10 bytes, and returns 10?  I think the intention of the composer
> of the page was to emphasize that the number of items returned is not
> necessarily the number of bytes.
>
>> How could this information be useful?
>
>  1. It is an accurate description.
>  2. The current phrasing is more confusing for beginners.
>
>  I also slightly rephrased it:
[...]

Sorry. I was a hasty reading your patch--I noticed what you added, but
not what you removed ("(i.e., not the number of characters)"). I think
that your change does improve the page. I've applied a modified
version of your patch for upstream 3.39. The patch is shown below.

Cheers,

Michael

--- a/man3/fread.3
+++ b/man3/fread.3
@@ -40,7 +40,7 @@
 .\" Modified Thu Apr 20 20:43:53 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
 .\" Modified Fri May 17 10:21:51 1996 by Martin Schulze
<joey@infodrom.north.de>
 .\"
-.TH FREAD 3  1996-05-17 "GNU" "Linux Programmer's Manual"
+.TH FREAD 3  2012-03-30 "GNU" "Linux Programmer's Manual"
 .SH NAME
 fread, fwrite \- binary stream input/output
 .SH SYNOPSIS
@@ -79,13 +79,18 @@ obtaining them from the location given by
 For nonlocking counterparts, see
 .BR unlocked_stdio (3).
 .SH "RETURN VALUE"
+On success,
 .BR fread ()
 and
 .BR fwrite ()
-return the number of items successfully read or written (i.e., not the
-number of characters).
-If an error occurs, or the end-of-file is
-reached, the return value is a short item count (or zero).
+return the number of
+.I items
+read or written.
+This number equals the number of bytes transferred only when
+.I size
+is 1.
+If an error occurs, or the end of the file is reached,
+the return value is a short item count (or zero).
 .PP
 .BR fread ()
 does not distinguish between end-of-file and error, and callers must use

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/




Added tag(s) fixed-upstream. Request was from "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> to control@bugs.debian.org. (Thu, 29 Mar 2012 19:00:05 GMT) Full text and rfc822 format available.

Added tag(s) pending. Request was from Simon Paillard <spaillard@debian.org> to control@bugs.debian.org. (Sat, 28 Apr 2012 21:22:19 GMT) Full text and rfc822 format available.

Reply sent to Simon Paillard <spaillard@debian.org>:
You have taken responsibility. (Wed, 09 May 2012 10:54:17 GMT) Full text and rfc822 format available.

Notification sent to Regid Ichira <regid23@yahoo.com>:
Bug acknowledged by developer. (Wed, 09 May 2012 10:54:18 GMT) Full text and rfc822 format available.

Message #29 received at 665780-close@bugs.debian.org (full text, mbox):

From: Simon Paillard <spaillard@debian.org>
To: 665780-close@bugs.debian.org
Subject: Bug#665780: fixed in manpages 3.40-0.1
Date: Wed, 09 May 2012 10:48:16 +0000
Source: manpages
Source-Version: 3.40-0.1

We believe that the bug you reported is fixed in the latest version of
manpages, which is due to be installed in the Debian FTP archive:

manpages-dev_3.40-0.1_all.deb
  to main/m/manpages/manpages-dev_3.40-0.1_all.deb
manpages_3.40-0.1.diff.gz
  to main/m/manpages/manpages_3.40-0.1.diff.gz
manpages_3.40-0.1.dsc
  to main/m/manpages/manpages_3.40-0.1.dsc
manpages_3.40-0.1_all.deb
  to main/m/manpages/manpages_3.40-0.1_all.deb
manpages_3.40.orig.tar.gz
  to main/m/manpages/manpages_3.40.orig.tar.gz



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 665780@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Simon Paillard <spaillard@debian.org> (supplier of updated manpages package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sun, 06 May 2012 15:24:57 +0200
Source: manpages
Binary: manpages manpages-dev
Architecture: source all
Version: 3.40-0.1
Distribution: unstable
Urgency: low
Maintainer: Martin Schulze <joey@debian.org>
Changed-By: Simon Paillard <spaillard@debian.org>
Description: 
 manpages   - Manual pages about using a GNU/Linux system
 manpages-dev - Manual pages about using GNU/Linux for development
Closes: 147778 156154 202022 337581 607398 614881 655088 656994 659750 664688 665780 667672
Changes: 
 manpages (3.40-0.1) unstable; urgency=low
 .
   * Non-maintainer upload.
   * debian/watch: kernel.org is back
   * Install sigwait.3, no more conflict with glibc-doc (Closes: #147778)
   * Imported Upstream version 3.40:
     . new manpages: getent.1 process_vm_readv.2 sendmmsg.2 get_nprocs_conf.3
         malloc_get_state.3 malloc_trim.3 malloc_usable_size.3 mallopt.3
         mcheck.3 scandirat.3
     . pipe.2: Add "#include <fntl.h>" for O_* constants (Closes: #659750)
     . resolv.conf.5:
         - Describe syntax used for comments (Closes: #656994)
         - Document "single-request" option (Closes: #607398)
     . rtnetlink.3: fix example (Closes: #655088)
     . dbopen.3 and db related: refer to libdb API (Closes: #337581)
     . fread.3: return value is number of items, not bytes (Closes: #665780)
     . gettimeofday.2: mark DST_ constants as obsolete (Closes: #614881)
     . rcmd.3: Document "_af" variants of these functions (Closes: #202022)
     . iso_8859-1.7: Add "-" for SOFT HYPHEN (Closes: #156154)
     . keyctl.2: Strip trailing tabs from source line (Closes: #664688)
   * debian/control:
     . Replace libc-bin (<< 2.13-31) as getent.1 is now provided by manpages
     . Bump Standards-Version to 3.9.3
   * debian/inst: install section 1 in manpages binary package.
   * mallopt.3: switch to the upstream version
   * motd.tail(5): fix groff warnings, two spaces instead of one after period
     (Closes: #667672) - thanks to Bjarni Ingi Gislason
Checksums-Sha1: 
 715f38680a0d767e04e8c0c7b9923331cc1ac50a 1863 manpages_3.40-0.1.dsc
 0e0aa536815f49522932c0985461a8d2de610a80 1723615 manpages_3.40.orig.tar.gz
 83806793e06e9cd4674e758e09743645eb3d2a6f 47786 manpages_3.40-0.1.diff.gz
 f3fa7c79a7a09f86c34dfd8b7cafebd4073c251b 775560 manpages_3.40-0.1_all.deb
 4a2538b3213aed070ff6401fda94528286bcd89f 1710474 manpages-dev_3.40-0.1_all.deb
Checksums-Sha256: 
 2d7152d1ccfe8b35eb2f349e6b4c7d7a76c95440b3335556e90badcb8f47d4f5 1863 manpages_3.40-0.1.dsc
 0f30f8168d85a12f6032217a44df484ef7f1a9c1c8d7bace1faa2d10f8629cff 1723615 manpages_3.40.orig.tar.gz
 619cb6deb8b1238329be47b62a0aeebbdbff78b3d79357859c60e944f701274e 47786 manpages_3.40-0.1.diff.gz
 a86e1732a78c94fc31a3b1bc15b97db6198c7946b6d9af7435c4d330ee5e785b 775560 manpages_3.40-0.1_all.deb
 3d3054f8c7106163059ecc8c5feeb1e877dd0a4ccea90199ed9b584323800eb8 1710474 manpages-dev_3.40-0.1_all.deb
Files: 
 ea22ee1cfdc1b9c8f9462607a5cdc191 1863 doc important manpages_3.40-0.1.dsc
 41f40b4890c2f463840ed7070e68ab3a 1723615 doc important manpages_3.40.orig.tar.gz
 1a4a36695e7e1474158f89d3d6c2e0c8 47786 doc important manpages_3.40-0.1.diff.gz
 ac8c8898a6901f20302674c26351f98b 775560 doc important manpages_3.40-0.1_all.deb
 4d890750faca36c152cd419f1a599ae5 1710474 doc optional manpages-dev_3.40-0.1_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBCAAGBQJPpnzuAAoJEN/3OMLRbPuiJcUP/2bfsQVxrYW/wRJsJc0yL1ax
1FU6DuFntKl9GEciyY8pOBFBh+9DlbO+kbpnPar2xlGAQi+J2e6qvSQ2V2M8cx5o
mcPrF1Sv1XWQ+Bm1DHA22Mzj/vYFKpFAaxwzT/KWbtLVrkH+G5gHlpHotMWE5Bmf
897bvAPuK8qcJkvLtPIAxpFzXKtnxw89PUYx71ig6jrfonVuSJQvFpzb90DZfz2F
gKGfpkJePKe0i1nzz6dNeoPk48sgKstp7lrTR5+9Ub/NTLTMzPzBT9QK4RBD2gMV
le22NNt26pk0O79KrabjabZRUYsC+7oOvWJqPE3y4R53tCZzeIlFMC56pWHGpmD2
hsOXLmnfgPjwuwFG2vqBKdCuKmvtav3RwUSFjhbh/0Vw3+voT5VdBBsrlmvuiQdC
v47/KU6+YLT5CDQhF4Up/YQleX0cgn47/z5dauAIeZqzJxmm3rhpdLSGtV4eUJje
Utsros+CV2fUK6vO2WBx7pr9hfKFH9JGnegkjm/F50EzMqdKSOIJFzFAaBPK0hxd
v4AXAZuquax69wyYPMWBA0FWS+qq94QNNjw9PLj8RkwBmZOCRdGV8efyQhDrkcVQ
aip6PMXHsirUrWfbXHe2pChPJdQIyobDV3rv+B9Ua1JdBYim8wWMHqSv2hOsBmBW
DH9THUg+wnrvuxIbkPnG
=wlDY
-----END PGP SIGNATURE-----





Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Sun, 17 Jun 2012 07:52:08 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 23 18:24:19 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.