Thread (4 messages) 4 messages, 1 author, 2021-11-23

[Bug 215097] Example in getpwnam_r man page compares size_t variable to -1

flat view

From: <hidden>
Date: 2021-11-23 11:47:24
Subsystem: the rest · Maintainer: Linus Torvalds

https://bugzilla.kernel.org/show_bug.cgi?id=215097
--- Comment #3 from Alejandro Colomar (man-pages) (alx.manpages@gmail.com) ---
Makes sense.  Fixed.
I'll keep the bug open until I fix sysconf(3) too.

Thanks!
Alex

    getpwnam.3: EXAMPLES: Fix signedness

    sysconf(3) returns a long.  Since it can return -1 (and we're
    making use of that value), we can't use size_t for bufsize.
    Use long.

    Link: <https://bugzilla.kernel.org/show_bug.cgi?id=215097>
    Reported-by: Fabian [off-list ref]
    Signed-off-by: Alejandro Colomar [off-list ref]
diff --git a/man3/getpwnam.3 b/man3/getpwnam.3
index 71457a916..8ca13f1a2 100644
--- a/man3/getpwnam.3
+++ b/man3/getpwnam.3
@@ -304,7 +304,7 @@ main(int argc, char *argv[])
     struct passwd pwd;
     struct passwd *result;
     char *buf;
-    size_t bufsize;
+    long bufsize;
     int s;

     if (argc != 2) {
-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help