Bug 268028 - Remove unneeded sys/types.h include
Summary: Remove unneeded sys/types.h include
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL:
Keywords: standards
Depends on:
Blocks:
 
Reported: 2022-11-28 04:34 UTC by Guilherme Janczak
Modified: 2024-01-10 03:33 UTC (History)
3 users (show)

See Also:


Attachments
The patch. (3.42 KB, patch)
2022-11-28 04:34 UTC, Guilherme Janczak
no flags Details | Diff
Test if unistd.h functions need sys/types.h (481 bytes, text/plain)
2022-11-29 04:20 UTC, Guilherme Janczak
no flags Details
Test if termios.h functions need sys/types.h (129 bytes, text/plain)
2022-11-29 04:20 UTC, Guilherme Janczak
no flags Details
Test if pwd.h functions need sys/types.h (110 bytes, text/plain)
2022-11-29 04:21 UTC, Guilherme Janczak
no flags Details
Test if sys/ipc.h functions need sys/types.h (113 bytes, text/plain)
2022-11-29 04:22 UTC, Guilherme Janczak
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guilherme Janczak 2022-11-28 04:34:33 UTC
Created attachment 238386 [details]
The patch.

Most of the affected man pages are of standard functions which are defined by POSIX not to need a sys/types.h include. Only setproctitle.3 and tcsetsid.3 are not standard functions. In both cases, I've verified that the other headers these functions require include all the necessary type declarations.

This unnecessary include seems to be a minor but recurring issue in FreeBSD man pages as evidenced by these past commits:
https://cgit.freebsd.org/src/log/lib/libc?id=310d2ce0f6835de3754d8f7f1da304c66440ffd3&qt=grep&q=sys%2Ftypes.h
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2022-11-28 22:53:17 UTC
Did you wrote (small) test programs for each of the function, to check
that it still compiles without sys/types.h?  If yes, could you please share
the tests?
Comment 2 Guilherme Janczak 2022-11-29 04:20:11 UTC
Created attachment 238411 [details]
Test if unistd.h functions need sys/types.h
Comment 3 Guilherme Janczak 2022-11-29 04:20:34 UTC
Created attachment 238412 [details]
Test if termios.h functions need sys/types.h
Comment 4 Guilherme Janczak 2022-11-29 04:21:11 UTC
Created attachment 238413 [details]
Test if pwd.h functions need sys/types.h
Comment 5 Guilherme Janczak 2022-11-29 04:22:00 UTC
Created attachment 238414 [details]
Test if sys/ipc.h functions need sys/types.h
Comment 6 Guilherme Janczak 2022-11-29 04:26:19 UTC
(In reply to Konstantin Belousov from comment #1)

Sorry, I'm not a FreeBSD user, I've only read the source code.
I just wrote a test for each header and attached them to this bug report, I haven't tried the tests on a FreeBSD system.
Comment 7 Warner Losh freebsd_committer freebsd_triage 2022-11-29 16:59:36 UTC
General note: we already test to make sure that many headers can be included on their own. We don't test, though, if the proper functions are defined by them.
We may need to augment those tests, but they don't replace the ones that Guilherme has uploaded.

I also think this is the right thing to do to the man pages, but will let kib@ drive
Comment 8 Konstantin Belousov freebsd_committer freebsd_triage 2022-11-29 22:44:53 UTC
(In reply to Guilherme Janczak from comment #3)
s/tcsetid/tcsetsid/

Otherwise all tests look good, thank you.
Comment 9 commit-hook freebsd_committer freebsd_triage 2022-11-29 22:46:12 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a6d40b0ad2c51e16a8c99750d5ed6f9aea2be7d4

commit a6d40b0ad2c51e16a8c99750d5ed6f9aea2be7d4
Author:     Guilherme Janczak <guilherme.janczak@yandex.com>
AuthorDate: 2022-11-28 22:57:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-11-29 22:45:07 +0000

    libc: remove unneeded sys/types.h include from several synopses

    PR:     268028
    Reviewed by:    kib
    Discussed with: imp
    MFC after:      1 week

 lib/libc/gen/ftok.3         | 3 +--
 lib/libc/gen/getpeereid.3   | 3 +--
 lib/libc/gen/getpwent.3     | 3 +--
 lib/libc/gen/setproctitle.3 | 3 +--
 lib/libc/gen/tcgetpgrp.3    | 3 +--
 lib/libc/gen/tcgetsid.3     | 3 +--
 lib/libc/gen/tcsetpgrp.3    | 3 +--
 lib/libc/gen/tcsetsid.3     | 3 +--
 8 files changed, 8 insertions(+), 16 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-12-06 04:07:38 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5b6f0a5012e9bc37dcb32b57b41e2443a46da620

commit 5b6f0a5012e9bc37dcb32b57b41e2443a46da620
Author:     Guilherme Janczak <guilherme.janczak@yandex.com>
AuthorDate: 2022-11-28 22:57:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-12-06 04:06:23 +0000

    libc: remove unneeded sys/types.h include from several synopses

    PR:     268028

    (cherry picked from commit a6d40b0ad2c51e16a8c99750d5ed6f9aea2be7d4)

 lib/libc/gen/ftok.3         | 3 +--
 lib/libc/gen/getpeereid.3   | 3 +--
 lib/libc/gen/getpwent.3     | 3 +--
 lib/libc/gen/setproctitle.3 | 3 +--
 lib/libc/gen/tcgetpgrp.3    | 3 +--
 lib/libc/gen/tcgetsid.3     | 3 +--
 lib/libc/gen/tcsetpgrp.3    | 3 +--
 lib/libc/gen/tcsetsid.3     | 3 +--
 8 files changed, 8 insertions(+), 16 deletions(-)
Comment 11 Graham Perrin 2023-09-24 06:30:27 UTC
Since manual pages were updated last year, 

(In reply to Warner Losh from comment #7)
(In reply to Konstantin Belousov from comment #8)

– please, what remains to do in this report? 

----

^Triage: 

* summary, keywords
* CC freebsd-doc@
* in progress but not assigned to a person (noted, not changed).
Comment 12 Mark Linimon freebsd_committer freebsd_triage 2024-01-10 03:33:19 UTC
^Triage: assign to committer that resolved.

Apparently this was MFCed to 13.  MFCs to 12 are now OBE.