Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/: Some improvements to sizes of array parameters #1134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Nov 27, 2024

The first commit is just readability stuff, but the second one is an important safety improvement.

Cc: @uecker


Revisions:

v1b
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  208d2461 = 1:  21a2e3d7 lib/alloc/: Compact parameter names
2:  6652239e = 2:  74c8c193 lib/string/: Use array notation with forward declarations
v1c
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  21a2e3d7 = 1:  c6b33e71 lib/alloc/: Compact parameter names
2:  74c8c193 = 2:  108e00b2 lib/string/: Use array notation with forward declarations
v1d
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  c6b33e71 = 1:  ec3e7478 lib/alloc/: Compact parameter names
2:  108e00b2 = 2:  839aa80e lib/string/: Use array notation with forward declarations
v1e
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  ec3e7478 = 1:  ed3d9a60 lib/alloc/: Compact parameter names
2:  839aa80e = 2:  fea5bcf1 lib/string/: Use array notation with forward declarations
v1f
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  ed3d9a60 = 1:  639a287d lib/alloc/: Compact parameter names
2:  fea5bcf1 = 2:  40bd9363 lib/string/: Use array notation with forward declarations
v1g
  • Rebase
$ git range-diff alx/master..gh/arrayparam master..arrayparam 
1:  639a287d = 1:  b20779a4 lib/alloc/: Compact parameter names
2:  40bd9363 = 2:  91af1e44 lib/string/: Use array notation with forward declarations
v1h
  • Rebase
$ git range-diff alx/master..gh/arrayparam master..arrayparam 
1:  b20779a4 = 1:  3c3052ad lib/alloc/: Compact parameter names
2:  91af1e44 = 2:  133e9cca lib/string/: Use array notation with forward declarations
v1i
  • Rebase
$ git range-diff master..gh/arrayparam shadow/master..arrayparam 
1:  3c3052ad = 1:  a03c31a6 lib/alloc/: Compact parameter names
2:  133e9cca = 2:  b0589f79 lib/string/: Use array notation with forward declarations

@alejandro-colomar alejandro-colomar marked this pull request as ready for review November 27, 2024 12:43
lib/alloc/x/xmalloc.h Dismissed Show resolved Hide resolved
lib/alloc/x/xmalloc.h Dismissed Show dismissed Hide dismissed
lib/string/sprintf/snprintf.h Dismissed Show dismissed Hide dismissed
lib/string/strcpy/strtcpy.h Dismissed Show dismissed Hide dismissed
@alejandro-colomar alejandro-colomar force-pushed the arrayparam branch 4 times, most recently from 839aa80 to fea5bcf Compare December 6, 2024 12:08
@alejandro-colomar
Copy link
Collaborator Author

Queued after the release of 4.17.0.

@alejandro-colomar alejandro-colomar marked this pull request as draft December 6, 2024 12:16
@alejandro-colomar alejandro-colomar marked this pull request as ready for review December 22, 2024 12:03
@alejandro-colomar alejandro-colomar added the Simpler A good issue for a new beginner label Dec 22, 2024
'n' is just as meaningful as 'nmemb', and is in more common use in C
projects (including this one).

Signed-off-by: Alejandro Colomar <[email protected]>
GNU C has an extension which allows to forward-declare parameters, so
that array notation can be used with sizes that are defined after the
array itself.

This improves the safety of such arrays, by telling the compiler the
bounds of the array.

This feature has been proposed for standardization in C2y as n3394.

Link: n3394 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3394.pdf>
Cc: Martin Uecker <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Simpler A good issue for a new beginner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant