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 2020-10-09 08:38
Reporter alanc View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Alan Coopersmith
User Reference
Section fstatat()
Page Number 951
Line Number 32669
Interp Status ---
Final Accepted Text
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 No tags attached.
Attached Files

- Relationships

-  Notes
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.

- 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

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