[Bug 96207] Comments of a sockaddr_un structure could confuse one

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 04 Jul 2024 08:43:57 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=96207

Amanda Steele <puzzlingcoalore@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |puzzlingcoalore@gmail.com

--- Comment #3 from Amanda Steele <puzzlingcoalore@gmail.com> ---
(In reply to Rostislav Krasny from comment #0)https://scratchgeometrydash.com
Change the comment /* sockaddr len including null */ to /* sockaddr_un len
without NUL */.
Change the comment /* path name (gag) */ to /* NUL-terminated path name */.
These changes align with the correct interpretation of the sockaddr_un
structure and the SUN_LEN(su) macro, as they clarify the intent and the
behavior of the code.

Here is the updated sockaddr_un structure with the revised comments:
/*
 * Definitions for UNIX IPC domain.
 */
struct sockaddr_un {
    unsigned char   sun_len;        /* sockaddr_un len without NUL */
    sa_family_t     sun_family;     /* AF_UNIX */
    char            sun_path[104];  /* NUL-terminated path name */
};

/* actual length of an initialized sockaddr_un */
#define SUN_LEN(su) \
    (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
This should clarify the intended usage and prevent misunderstandings for future
developers working with this code.

To make these changes effective in the FreeBSD project, you would typically:

Propose the changes through the appropriate FreeBSD mailing list or bug
tracker.
Provide a patch with the updated comments.
Reference the discussion and the rationale behind the change to explain the
reasoning to other developers and maintainers.
The links to the NetBSD discussion and commit logs can serve as additional
context to support your proposal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.