Alejandro Colomar
f723e17664
ptrdiff_t.3: New link to new documented type in system_data_types(7)
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:19:56 +02:00
Alejandro Colomar
515348d543
system_data_types.7: Document ptrdiff_t
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:19:07 +02:00
Alejandro Colomar
dd06f85245
system_data_types.7: wfix: sort referenced types
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:16:09 +02:00
Alejandro Colomar
b6d3f94f29
system_data_types.7: srcfix: Remove TODO comment
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:15:38 +02:00
Michael Kerrisk
c72ab20dc8
system_data_types.7: Add read(2) and write(2) to "See also" for size_t
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:08:02 +02:00
Alejandro Colomar
231b22152a
size_t.3: New link to new documented type in system_data_types(7)
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:06:55 +02:00
Alejandro Colomar
eb3f724506
system_data_types.7: Document size_t
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-18 22:06:50 +02:00
Michael Kerrisk
3006c18803
feature_test_macros.7: tfix
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 22:54:01 +02:00
Michael Kerrisk
9f2a6007d1
intro.2, intro.3, feature_test_macros.7, standards.7: SEE ALSO: add system_data_types(7)
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 22:54:01 +02:00
Michael Kerrisk
866c73c89f
system_data_types.7: Add SEE ALSO references to feature_test_macros(7) and standards(7)
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 22:54:01 +02:00
Alejandro Colomar
9334a43e41
sigval.3, ssize_t.3, suseconds_t.3, time_t.3, timer_t.3, timespec.3, timeval.3: New links to new system_data_types(7) page
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 22:54:01 +02:00
Alejandro Colomar
cb7fd5031a
system_data_types.7: Add a new page to document system data types
...
The initial version documents sigval, ssize_t, suseconds_t,
time_t, timer_t, timespec, and timeval.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 22:37:57 +02:00
Marko Hrastovec
a23b00988a
freeaddrinfo.3: Fix memory leaks in freeaddrinfo() examples
...
[mtk: the coding style used in the example could lead people to
inject memory leaks in their code if they cut/paste/modify the
code to replace "exit" paths with "return" paths from a library
function.]
[Marko, from the mail thread discussing this patch:]
You are right about terminating the process. However, people copy
that example and put the code in a function changing "exit" to
"return". There are a bunch of examples like that here
https://beej.us/guide/bgnet/html/#poll , for instance. That error
bothered me when reading the network programming guide
https://beej.us/guide/bgnet/html/ . Than I looked for information
elsewhere:
https://stackoverflow.com/questions/6712740/valgrind-reporting-that-getaddrinfo-is-leaking-memory
https://stackoverflow.com/questions/15690303/server-client-sockets-freeaddrinfo3-placement
And finally, I checked manual pages and saw where these errors
come from.
When you change that to a function and return without doing
freeaddrinfo, that is a memory leak. I believe an example should
show good programming practices. Relying on exiting and clearing
the memory in that case is not such a case. In my opinion, these
examples lead people to make mistakes in their programs.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-17 09:12:24 +02:00
Michael Kerrisk
966d17b1c5
sigaction.2: Use correct POSIX type for siginfo_t.si_value
...
Reported-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-16 16:26:12 +02:00
Michael Kerrisk
15e2ed1500
man-pages.7: Add some more requests re code examples
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-15 10:44:00 +02:00
Michael Kerrisk
6e68441741
man-pages.7: Soften the statement that ideal programs should be short
...
Sometimes, a longer program is needed. See
https://twitter.com/shuveb/status/1305689727715086337 .
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-15 10:43:20 +02:00
Michael Kerrisk
1aaa7bcd6a
fanotify.7: ffix
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-15 07:39:27 +02:00
Alejandro Colomar
8eb90116f1
add_key.2, clock_getres.2, clone.2, futex.2, getdents.2, getpid.2, getrlimit.2, ioctl_ns.2, kcmp.2, keyctl.2, memfd_create.2, request_key.2, stat.2, timer_create.2, wait.2, clock_getcpuclockid.3, dl_iterate_phdr.3, getgrent_r.3, getpwent_r.3, getpwnam.3, posix_spawn.3, pthread_getcpuclockid.3, strcat.3, feature_test_macros.7, user_namespaces.7: Switch printf() casts to use [u]intmax_t + %ju / %jd
...
Let's move to the 21st century. Instead of casting system data
types to long/long long/etc. in printf() calls, instead cast to
intmax_t or uintmax_t, the largest available signed/unsigned
integer types.
[mtk: rewrote commit message]
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-15 07:39:19 +02:00
Alejandro Colomar
6fd153d540
clock_getres.2: Cast 'time_t' to 'int' for printf() and fix the length modifiers
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Reviewed-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 08:07:05 +02:00
Alejandro Colomar
f6fbffeae5
userfaultfd.2: Use 'PRIx64' rather than "%llx" when printing 64-bit fixed-width types
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 08:07:05 +02:00
Alejandro Colomar
adb2084109
rtld-audit.7: Use "%u" rather than "%d" when printing 'unsigned int' values
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 08:07:05 +02:00
Alejandro Colomar
1bdfc7fc42
open_by_handle_at.2: Use "%u" rather than "%d" when printing 'unsigned int' values
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 08:07:05 +02:00
Alejandro Colomar
982dfed192
mprotect.2: Use "%p" rather than casting to 'long' when printing pointer values
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 08:06:46 +02:00
Alejandro Colomar
627a256ed6
malloc_hook.3: Remove unneeded cast, and print 'size_t' with "%zu"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-13 07:44:06 +02:00
Alejandro Colomar
dc97703b4a
eventfd.2, mprotect.2, pidfd_open.2, spu_run.2, timer_create.2, bswap.3, dl_iterate_phdr.3, endian.3, pthread_attr_init.3, pthread_getattr_np.3, vcs.4, rtld-audit.7: In printf(): s/0x%/%#/ except when followed by X instead of x
...
Use printf()'s '#' flag character to prepend the string "0x".
However, when the number is printed in uppercase, and the prefix
is in lowercase, the string "0x" needs to be manually written.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-12 08:38:20 +02:00
Alejandro Colomar
ec8b00033c
getaddrinfo_a.3: Use C99 style to declare loop counter variables
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-12 08:38:20 +02:00
Alejandro Colomar
ae85f653e4
msgctl.2, outb.2, abs.3, dl_iterate_phdr.3, drand48.3, drand48_r.3, encrypt.3, ffs.3, lrint.3, lround.3, ntp_gettime.3, printf.3, random.3, scalbln.3, scanf.3, strtol.3, strtoul.3, utmp.5, feature_test_macros.7, rtld-audit.7: Omit 'int' keyword for 'short', 'long' and 'long long' types, both signed and 'unsigned'
...
For consistency.
The types are written both with and without the redundant 'int' keyword
all over the man-pages. However, the most used form, by far, is the one
without 'int'.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-12 08:37:41 +02:00
Michael Kerrisk
7d9746136e
pthread_attr_init.3, pthread_create.3, pthread_getattr_np.3: Use correct type (size_t) for some variables
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 14:24:56 +02:00
Michael Kerrisk
404990aeb9
pthread_getattr_np.3: tfix
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 14:22:59 +02:00
Michael Kerrisk
68041421a1
userfaultfd.2: Use a better type (uint64_t) for 'len' in EXAMPLES
...
See the previous commit to bswap.3...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 14:19:24 +02:00
Jakub Wilk
581c3ea730
bswap.3: Use strtoull() for parsing 64-bit numbers
...
Before, on 32-bit systems:
$ ./a.out 0x0123456789abcdef
0xffffffff ==> 0xffffffff00000000
After:
$ ./a.out 0x0123456789abcdef
0x123456789abcdef ==> 0xefcdab8967452301
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 14:11:10 +02:00
Alejandro Colomar
0ef3e1b730
clock_getcpuclockid.3: Remove unneeded cast
...
Member 'tv_nsec' of 'struct timespec' is of type 'long' (see time.h.0p),
and therefore, the cast is completely redundant.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 13:04:21 +02:00
Alejandro Colomar
ea7dc0bdcf
stat.2: wsfix
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:36:05 +02:00
Michael Kerrisk
fbd150d909
timerfd_create.2: ffix
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
76db89d368
stat.2: Cast to 'unsigned long' rather than 'long' when printing with "%lx"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
e080a90f48
ioctl_ns.2: Cast to 'unsigned long' rather than 'long' when printing with "%lx"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Michael Kerrisk
49f06c0010
pthread_setname_np.3: ffix
...
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
77de385db6
eventfd.2: Use 'PRIxN' macros when printing C99 fixed-width integer types
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
86d90299ae
timerfd_create.2: Use 'PRIxN' macros when printing C99 fixed-width integer types
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
95cc0897f7
core.5: Use adequate type
...
'nread' is of type 'ssize_t'
'tot' adds up different values contained in 'nread',
so it should also be 'ssize_t', and not 'int' (which possibly overflows).
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
b9bf902972
unix.7: Use sizeof() to get buffer size (instead of hardcoding macro name)
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
cbb22338cf
fread.3: Move ARRAY_SIZE logic into macro
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:28 +02:00
Alejandro Colomar
3996bc9c26
timer_create.2: Cast to 'unsigned long' rather than 'long' when printing with "%lx"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 11:33:20 +02:00
Alejandro Colomar
c9e2544b17
request_key.2: Cast to 'unsigned long' rather than 'long' when printing with "%lx"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 09:51:12 +02:00
Alejandro Colomar
53de137678
add_key.2: Cast to 'unsigned long' rather than 'long' when printing with "%lx"
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 09:50:32 +02:00
Alejandro Colomar
1656c1702d
getpwent_r.3: Use sizeof() to get buffer size (instead of hardcoding macro name)
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 09:17:50 +02:00
Alejandro Colomar
cf254328fe
getgrent_r.3: Use sizeof() to get buffer size (instead of hardcoding macro name)
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 09:17:45 +02:00
Alejandro Colomar
6da4ee9147
membarrier.2: Note that glibc does not provide a wrapper
...
Notes: I copied .nf and .fi from futex.2, but they made no visual difference.
What do they actually do?
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 08:44:48 +02:00
Alejandro Colomar
9a84e3383f
get_phys_pages.3: Write 'long' instead of 'long int'
...
For consistency.
Most man pages use 'long' instead of 'long int'.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 08:43:37 +02:00
Alejandro Colomar
4e4e6e5e14
getpwent_r.3: Declare variables with different types in different lines
...
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-11 08:43:14 +02:00