Skip to content

Conversation

@alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Dec 7, 2024

While at it, rename the function parameter.

v1b
  • Rebase
$ git range-diff alx/master..gh/strdup_ master..strdup_ 
1:  9b9ee9c8 = 1:  e2169576 lib/: Simplify by calling strdup(3)
2:  b81ed41a = 2:  0d41e7a6 lib/: Remove arbitrary limitation by calling strdup(3)
3:  aab18a17 = 3:  77cf47bb lib/: Rename local variable
4:  a4efdf54 = 4:  0eff731b lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1c
  • Rebase
$ git range-diff alx/master..gh/strdup_ master..strdup_ 
1:  e2169576 = 1:  39ab645a lib/: Simplify by calling strdup(3)
2:  0d41e7a6 = 2:  698435c5 lib/: Remove arbitrary limitation by calling strdup(3)
3:  77cf47bb = 3:  4f54e215 lib/: Rename local variable
4:  0eff731b = 4:  410ba3fb lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1d
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  39ab645a = 1:  16793a90 lib/: Simplify by calling strdup(3)
2:  698435c5 = 2:  171d9908 lib/: Remove arbitrary limitation by calling strdup(3)
3:  4f54e215 = 3:  bfc747a8 lib/: Rename local variable
4:  410ba3fb = 4:  d9c502a6 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1e
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  16793a90 = 1:  9978c231 lib/: Simplify by calling strdup(3)
2:  171d9908 = 2:  61bf4c55 lib/: Remove arbitrary limitation by calling strdup(3)
3:  bfc747a8 = 3:  ada9c214 lib/: Rename local variable
4:  d9c502a6 = 4:  cb73a7f4 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1f
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  9978c231 = 1:  a10ecdd5 lib/: Simplify by calling strdup(3)
2:  61bf4c55 = 2:  0d94a5e5 lib/: Remove arbitrary limitation by calling strdup(3)
3:  ada9c214 = 3:  6e768061 lib/: Rename local variable
4:  cb73a7f4 = 4:  f725ab52 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1g
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  a10ecdd5 = 1:  44f549c5 lib/: Simplify by calling strdup(3)
2:  0d94a5e5 = 2:  e5cf9282 lib/: Remove arbitrary limitation by calling strdup(3)
3:  6e768061 = 3:  fb5817ac lib/: Rename local variable
4:  f725ab52 = 4:  0f8175e3 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1h
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  44f549c5 = 1:  da087346 lib/: Simplify by calling strdup(3)
2:  e5cf9282 = 2:  e11dafc9 lib/: Remove arbitrary limitation by calling strdup(3)
3:  fb5817ac = 3:  f7b1b96a lib/: Rename local variable
4:  0f8175e3 = 4:  36c6929f lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1i
  • Rebase
$ git range-diff master..gh/strdup_ shadow/master..strdup_ 
1:  da087346 = 1:  5b3b1115 lib/: Simplify by calling strdup(3)
2:  e11dafc9 = 2:  82e35d46 lib/: Remove arbitrary limitation by calling strdup(3)
3:  f7b1b96a = 3:  e2170492 lib/: Rename local variable
4:  36c6929f = 4:  d2cd06c2 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1j
  • Rebase
$ git range-diff db/master..gh/strdup_ shadow/master..strdup_ 
1:  5b3b1115 = 1:  5af95419 lib/: Simplify by calling strdup(3)
2:  82e35d46 = 2:  a05afd2a lib/: Remove arbitrary limitation by calling strdup(3)
3:  e2170492 = 3:  f704fb45 lib/: Rename local variable
4:  d2cd06c2 = 4:  b2ff9d1f lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1k
  • Rebase
$ git rd 
1:  5af95419 = 1:  7f3b36fc lib/: Simplify by calling strdup(3)
2:  a05afd2a = 2:  d2d66280 lib/: Remove arbitrary limitation by calling strdup(3)
3:  f704fb45 = 3:  0693dafb lib/: Rename local variable
4:  b2ff9d1f = 4:  58f0fdd5 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1l
  • Rebase
$ git rd
1:  7f3b36fc = 1:  4923e07f lib/: Simplify by calling strdup(3)
2:  d2d66280 = 2:  4d684e4a lib/: Remove arbitrary limitation by calling strdup(3)
3:  0693dafb = 3:  0ec629df lib/: Rename local variable
4:  58f0fdd5 = 4:  0c63eda8 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
v1m
  • Rebase
$ git rd
1:  4923e07f = 1:  ea1fd365 lib/: Simplify by calling strdup(3)
2:  4d684e4a = 2:  806bb143 lib/: Remove arbitrary limitation by calling strdup(3)
3:  0ec629df = 3:  3827a35f lib/: Rename local variable
4:  0c63eda8 = 4:  1c836ba8 lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'

@alejandro-colomar alejandro-colomar force-pushed the strdup_ branch 4 times, most recently from 64c62b1 to b3cf85c Compare December 7, 2024 21:11
@alejandro-colomar alejandro-colomar changed the title lib/sgetgrent.c: sgetgrent(): Simplify by calling strdup(3) lib/: sget*ent(): Simplify by calling strdup(3) Dec 7, 2024
@alejandro-colomar alejandro-colomar mentioned this pull request Dec 9, 2024
@alejandro-colomar alejandro-colomar marked this pull request as ready for review December 22, 2024 12:05
@alejandro-colomar alejandro-colomar force-pushed the strdup_ branch 2 times, most recently from 410ba3f to d9c502a Compare January 24, 2025 14:57
@alejandro-colomar alejandro-colomar force-pushed the strdup_ branch 3 times, most recently from 0f8175e to 36c6929 Compare February 16, 2025 22:52
While at it, rename the function parameter.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This makes these APIs more consistent with the ones for groups,
which strdup(3) memory as necessary.

It also makes the code simpler.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Call it 'dup', which reminds that it's a strdup(3)d string.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Just like the other sget*ent() functions do.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Copy link
Member

@hallyn hallyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but is there any reason why you can't just drop the 'static' modifier and stop doing the first 'free'?

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented May 30, 2025

Looks good,

Thanks!

but is there any reason why you can't just drop the 'static' modifier and stop doing the first 'free'?

I remember having looked into it back then, but I don't remember my findings. :)

I'd like to attempt that in a separate PR in the future.

@hallyn
Copy link
Member

hallyn commented May 30, 2025

Ok, sounds good, thanks.

@hallyn hallyn merged commit 5bff501 into shadow-maint:master May 30, 2025
10 checks passed
@alejandro-colomar alejandro-colomar deleted the strdup_ branch May 30, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants