casaroli opened a new pull request, #3948:
URL: https://github.com/apache/nuttx-apps/pull/3948

   ## Summary
   
   POSIX declares `int putenv(char *string)`: the string itself becomes part of 
the environment, it is not copied. apache/nuttx#NNNNN makes NuttX do that. This 
PR prepares the two in-tree callers that do not work with it:
   
   - **testing/ostest: Pass a non-const string to putenv().** ostest passed a 
`const` array (`g_putenv_value`): "passing argument 1 of 'putenv' discards 
'const' qualifier", an error with `-Werror`. The array is now non-const; ostest 
does not change it, and it is static, so it stays valid while it is in the 
environment.
   - **interpreters/bas: Give a copy of the string to putenv().** The `ENVIRON` 
statement gave the string of a BASIC value to `putenv()` and then freed it with 
`Value_destroy()`. With a POSIX `putenv()` the environment then keeps a pointer 
to freed memory. It now gives `putenv()` a copy (`strdup()`), which stays in 
the environment.
   
   Merge order: this PR first, then apache/nuttx#NNNNN. Both changes also work 
with the current NuttX `putenv()` (`const char *`, copies the string). The 
NuttX PR has a `depends-on` line for this PR.
   
   ## Impact
   
   ostest and bas only. ostest: no behaviour change. bas: with the current 
NuttX, `putenv()` copies the string again, so each `ENVIRON` statement leaves 
one small copy that nothing frees, until the NuttX PR merges.
   
   ## Testing
   
   `qemu-armv8a:knsh` (kernel) and `qemu-armv8a:nsh` (flat), QEMU with HVF, 
NuttX master at 23f5a4f06df (7505b874722, #21072, does not build for arm64; 
fixed by #21210):
   
   | NuttX + apps | ostest knsh / nsh / flat nsh |
   |---|---|
   | master + apps master | 0 / 0 / 0 |
   | master + this PR | 0 / 0 / 0 |
   | NuttX PR + this PR | 0 / 0 / 0 |
   | NuttX PR + apps master | ostest does not build: `ostest_main.c:817` 
discards `const` (`-Werror=discarded-qualifiers`) |
   
   Builds with `EXTRAFLAGS="-Wno-cpp -Werror"` (as CI), with ostest and 
`CONFIG_INTERPRETERS_BAS`, `qemu-armv8a:nsh`: OK on NuttX master and on the 
NuttX PR, with `-Wno-error=array-bounds`. Without it, GCC 14.2 reports 
`-Werror=array-bounds` in `bas_statement.c:748-750` (`struct Identifier` has 
`char name[0]`), on apps master too; this PR does not change those lines.
   
   Style check: `tools/checkpatch.sh -c -u -m -g` passes for the ostest commit. 
For `interpreters/bas/bas_statement.c` it checks the whole file and reports 
1875 nxstyle errors, the same number as on master. 1633 of them are mixed-case 
identifiers of the third-party bas code (for example `Value_destroy()`), which 
a whitespace commit cannot fix; the others are older alignment, brace and 
declaration errors. codespell also reports the variable `inout`. The changed 
lines add no error.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to