add memdup_nul(), use it and memdup() in a few places
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest9 patches 5 repliesIn review
- v18 patches 9 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | string: fix prototype of memdup()include/ lib/ | +4 | 0 replies | |
| 2/9 | stdio: drop stdio_clonecommon/ include/ | +1 | 0 replies | |
| 3/9 | lib/string.c: drop pointless __HAVE_ARCH_STRDUPinclude/ lib/ | +1 | 0 replies | |
| 4/9 | lib/string.c: introduce memdup_nul() helperinclude/ lib/ | +28 | 0 replies | |
| 5/9 | lib/string.c: implement strdup() and strndup() in terms of memdup_nul()lib/ | +2 | 3 replies | |
| 6/9 | lib/hashtable.c: use memdup_nul() in himport_rlib/ | +3 | 0 replies | |
| 7/9 | common/cli.c: use memdup_nul() in run_command_list()common/ | +1 | 0 replies | |
| 8/9 | drivers/core: use memdup() instead of malloc()+memcpy()drivers/ drivers/ drivers/ | +3 | 0 replies | |
| 9/9 | test: lib: add test of memdup_nul()test/ | +34 | 1 reply |
Reviews trailers per patch
All 9 patches have a Reviewed-by or Acked-by.
| Patch | Simon Glass |
|---|---|
| 1/9 | R-b |
| 2/9 | R-b |
| 3/9 | R-b |
| 4/9 | R-b |
| 5/9 | R-b |
| 6/9 | R-b |
| 7/9 | R-b |
| 8/9 | R-b |
| 9/9 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/9] add memdup_nul(), use it and memdup() in a few places
There are quite a few places where we allocate X+1 bytes, initialize the first X bytes via memcpy() and then set the last byte to 0.
The kernel has a helper for that, kmemdup_nul(). Introduce a similar one, and start making use of it in a few places. Also the existing memdup() helper can be put to more use.
There are lots more places one could modify. But for code shared with host tools, one would need to do some refactoring, putting memdup() and memdup_nul() in their own str-util.c TU which could then also be included in the tools build.
v2: Fix grammar in commit msg, add Simon's R-B to patches 1-8, add test (new patch 9).
v1: https://lore.kernel.org/u-boot/[email protected]/
Rasmus Villemoes (9):
string: fix prototype of memdup()
stdio: drop stdio_clone
lib/string.c: drop pointless __HAVE_ARCH_STRDUP lib/string.c: introduce memdup_nul() helper lib/string.c: implement strdup() and strndup() in terms of
memdup_nul()
lib/hashtable.c: use memdup_nul() in himport_r common/cli.c: use memdup_nul() in run_command_list() drivers/core: use memdup() instead of malloc()+memcpy()
test: lib: add test of memdup_nul()
common/cli.c | 4 +--- common/stdio.c | 18 +-------------- drivers/core/acpi.c | 3 +-- drivers/core/ofnode.c | 3 +-- drivers/core/root.c | 3 +-- include/linux/string.h | 18 ++++++++++++--- include/stdio_dev.h | 1 - lib/hashtable.c | 7 +++--- lib/string.c | 51 +++++++++++++++--------------------------- test/lib/string.c | 34 ++++++++++++++++++++++++++++ 10 files changed, 75 insertions(+), 67 deletions(-)
Signature · 1 line
2.53.0