Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001409 [1003.1(2013)/Issue7+TC1] System Interfaces Editorial Enhancement Request 2020-10-08 16:48 2024-06-11 08:54
Reporter alanc View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Alan Coopersmith
Organization
User Reference
Section fstatat()
Page Number 951
Line Number 32669
Interp Status ---
Final Accepted Text Note: 0005238
Summary 0001409: Example code for stat() could use better function name
Description The example code for stat() currently has:

/* Print out type, permissions, and number of links. */
printf("%10.10s", sperm (statbuf.st_mode));
printf("%4d", statbuf.st_nlink);

It appears that "sperm" is supposed to be a user-provided function to
make a string representing the permission bits of the mode value, but
this isn't clear, and trying to do an internet search for "sperm" to
find if this function exists somewhere is extremely unhelpful.
Desired Action Use a better function name for the user provided function - perhaps strmode()
that actually exists on some systems, or a clearer made-up-name such as
permission_string() or mode_to_string(). Perhaps update the comment to
note that this is a user-supplied function, not part of the standard.
Tags tc3-2008
Attached Files

- Relationships

-  Notes
(0005039)
geoffclare (manager)
2020-10-09 08:38
edited on: 2020-10-09 08:41

The comment indicates that the type is included, so the new name should include "mode" not "perm". The name strmode() should not be used for a user-supplied function as str[a-z] is a reserved prefix for <string.h>. So I suggest either str_mode() or mode_string().

Also, the %4d is wrong because is assumes nlink_t is int (or promotes to int). That line should change to:
printf(" %4ju", (uintmax_t)statbuf.st_nlink);
The later lines that print st_gid and st_uid have the same problem.

(0005238)
geoffclare (manager)
2021-02-15 16:58

On C181 (TC2) page 968 lines 32917-32918 change:
printf("%10.10s", sperm (statbuf.st_mode));
printf("%4d", statbuf.st_nlink);
to:
printf("%10.10s", mode_string(statbuf.st_mode));
printf(" %4ju", (uintmax_t)statbuf.st_nlink);


On C181 (TC2) page 968 line 32923 change:
printf(" %-8d", statbuf.st_uid);
to:
printf(" %-8ju", (uintmax_t)statbuf.st_uid);


On C181 (TC2) page 968 line 32928 change:
printf(" %-8d", statbuf.st_gid);
to:
printf(" %-8ju", (uintmax_t)statbuf.st_gid);

- Issue History
Date Modified Username Field Change
2020-10-08 16:48 alanc New Issue
2020-10-08 16:48 alanc Name => Alan Coopersmith
2020-10-08 16:48 alanc Section => fstatat()
2020-10-08 16:48 alanc Page Number => 951
2020-10-08 16:48 alanc Line Number => 32669
2020-10-09 08:38 geoffclare Note Added: 0005039
2020-10-09 08:41 geoffclare Note Edited: 0005039
2021-02-15 16:58 geoffclare Note Added: 0005238
2021-02-15 17:00 geoffclare Interp Status => ---
2021-02-15 17:00 geoffclare Final Accepted Text => Note: 0005238
2021-02-15 17:00 geoffclare Status New => Resolved
2021-02-15 17:00 geoffclare Resolution Open => Accepted As Marked
2021-02-15 17:00 geoffclare Tag Attached: tc3-2008
2021-03-08 15:23 geoffclare Status Resolved => Applied
2024-06-11 08:54 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker