Commit 6508009
committed
rtld, libthr: Use
With Clang 21 at least, we start to get warnings like:
```
rtld.c:333:58: error: initializer-string for character array is too long, array size is 4 but initializer has size 5 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
333 | static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] = RTLD_UTRACE_SIG;
| ^~~~~~~~~~~~~~~
./rtld_utrace.h:49:27: note: expanded from macro 'RTLD_UTRACE_SIG'
49 | #define RTLD_UTRACE_SIG "RTLD"
|
```
Looking up the `nonstring` attribute [1], it does seem to be the correct
thing --- indicating a char array which should not have a null
terminator byte --- to use in these two cases.
Note: I discovered this when fixing Nixpkgs's FreeBSD cross compilation
support. I understand that FreeBSD may not officially support this
version of Clang yet, and so the CPP that is needed is a bit annoying.
But it still hopefully will make things easier once it comes time to
bump the supported version of Clang to one with this attribute.
I am hoping thus that this patch is acceptable, as just early readiness
for when FreeBSD does upgrade to that version of Clang.
[1]: https://clang.llvm.org/docs/AttributeReference.html#nonstring
Signed-off-by: John Ericson <[email protected]>nonstring attribute to silence compiler warning1 parent cb1315c commit 6508009
2 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
64 | | - | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
346 | 354 | | |
347 | 355 | | |
348 | 356 | | |
349 | 357 | | |
350 | 358 | | |
351 | | - | |
| 359 | + | |
352 | 360 | | |
353 | 361 | | |
354 | 362 | | |
| |||
0 commit comments