Page MenuHomeFreeBSD

<sys/extattr.h>: use designated initializers for EXTATTR_NAMESPACE_NAMES
AcceptedPublic

Authored by kevans on Tue, Feb 17, 5:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 15, 10:16 AM
Unknown Object (File)
Mon, Mar 9, 2:09 PM
Unknown Object (File)
Thu, Mar 5, 12:11 PM
Unknown Object (File)
Thu, Mar 5, 12:11 PM
Unknown Object (File)
Thu, Mar 5, 12:11 PM
Unknown Object (File)
Sun, Mar 1, 8:15 PM
Unknown Object (File)
Sun, Mar 1, 5:55 PM
Unknown Object (File)
Fri, Feb 27, 9:49 PM
Subscribers

Details

Reviewers
kib
mckusick
rmacklem
Group Reviewers
Klara
Summary

This is not a functional change, but it makes it more clear upon
inspection of the definition that the mapping property described is
preserved. Maybe more importantly, if one ends up getting an index
wrong or punching a hole in the name array unexpectedly, then it'll
hopefully manifest more clearly as a (null) or nullptr deref rather than
potentially just emitting the wrong namespace name.

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 70723
Build 67606: arc lint + arc unit

Event Timeline

AFAIR this is not a valid C++, if anybody cares.

This revision is now accepted and ready to land.Tue, Feb 17, 5:13 AM
In D55323#1265205, @kib wrote:

AFAIR this is not a valid C++, if anybody cares.

Yeah, seems to be true- FWIW, though, apparently clang and GCC both just accept it?

root@ifrit:/tmp # c++ test.cc
test.cc:5:30: warning: array designators are a C99 extension [-Wc99-designator]
    5 | const char * const names[] = EXTATTR_NAMESPACE_NAMES;
      |                              ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/extattr.h:60:2: note: expanded from macro 'EXTATTR_NAMESPACE_NAMES'
   60 |         [EXTATTR_NAMESPACE_EMPTY] = EXTATTR_NAMESPACE_EMPTY_STRING, \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
root@ifrit:/tmp # g++13 -Wall -Wextra test.cc

I'm a little surprised that GCC doesn't emit any kind of complaint as well.

gcc might need -pedantic or something like this.

Thanks for doing this. I think it does clarify
the relationship between EXTATTR_NAMESPACE_EMPTY
and EXTATTR_NAMESPACE_EMPTY_STRING for your
other patch.

This adds clarity for me.