Skip to contentSkip to conversation

printf 3

DISCUSSION Jon Grant 2 participants 4 messages Oct 3, 2011 – Oct 5, 2011 3 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

Jon Grant

author
#0 lore raw

Hello

Looking at this page:
http://man7.org/linux/man-pages/online/pages/man3/printf.3.html

"If an output error is encountered, a negative value is returned."

I am thinking if this could be clarified. If I call printf(NULL), errno is set to EINVAL, and -1 is returned.

Perhaps could be expanded to add:

"If a parameter error is encountered, errno set to EINVAL, and -1 is returned. If an output error is encountered, errno set EIO and -1 returned.

Best regards, Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to a message not in the archive

Hi Jon,

Quoted 7 lines · Jon Grant

Hello

Looking at this page:
http://man7.org/linux/man-pages/online/pages/man3/printf.3.html

"If an output error is encountered, a negative value is returned."

Quoted 7 lines

I am thinking if this could be clarified. If I call printf(NULL), errno is set to EINVAL, and -1 is returned.

Perhaps could be expanded to add:

"If a parameter error is encountered, errno set to EINVAL, and -1 is returned. If an output error is encountered, errno set EIO and -1 returned.

The apparently vague wording is deliberate. Glibc may generally return -1, but POSIX simply says "a negative value", and that's all that is guaranteed to an application.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#4 lore raw
In reply to a message not in the archive

Michael Kerrisk wrote, On 04/10/11 06:46:

Quoted 13 lines

Hi Jon,

Quoted 10 lines · Jon Grant

Hello

Looking at this page:
http://man7.org/linux/man-pages/online/pages/man3/printf.3.html

"If an output error is encountered, a negative value is returned."

I am thinking if this could be clarified. If I call printf(NULL), errno is set to EINVAL, and -1 is returned.

Quoted 8 lines
Quoted 4 lines

Perhaps could be expanded to add:

"If a parameter error is encountered, errno set to EINVAL, and -1 is returned. If an output error is encountered, errno set EIO and -1 returned.

The apparently vague wording is deliberate. Glibc may generally return -1, but POSIX simply says "a negative value", and that's all that is guaranteed to an application.

Ah ok. Good point.

Is it worth documenting the Glibc behaviour on the man page in addition to explaining POSIX spec.

Best regards, Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive
Quoted 23 lines · Jon Grant

Michael Kerrisk wrote, On 04/10/11 06:46:

Quoted 22 lines

Hi Jon,

Quoted 17 lines · Jon Grant

Hello

Looking at this page:
http://man7.org/linux/man-pages/online/pages/man3/printf.3.html

"If an output error is encountered, a negative value is returned."

I am thinking if this could be clarified. If I call printf(NULL), errno is
set to EINVAL, and -1 is returned.

Perhaps could be expanded to add:

"If a parameter error is encountered, errno set to EINVAL, and -1 is returned. If an output error is encountered, errno set EIO and -1 returned.

Quoted 8 lines
Quoted 3 lines

The apparently vague wording is deliberate. Glibc may generally return -1, but POSIX simply says "a negative value", and that's all that is guaranteed to an application.

Ah ok. Good point.

Is it worth documenting the Glibc behaviour on the man page in addition to explaining POSIX spec.

I don't think so in this case. It would mislead people into writing less portable code.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html