Skip to content

Commit ab0167b

Browse files
Revert "lib/shadow/: Use pointer to structure"
That change was temporary to allow adding a re-entrant variant of the function with a small diff. Remove it now that it's done. Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 246838b commit ab0167b

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

lib/shadow/group/sgetgrent.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,27 @@ struct group *
3333
sgetgrent(const char *s)
3434
{
3535
static char *buf = NULL;
36-
static struct group grent_ = {};
37-
struct group *grent = &grent_;
36+
static struct group grent = {};
3837

3938
int e;
4039
size_t n, lssize, size;
4140

4241
n = strchrcnt(s, ',') + 2;
43-
lssize = n * sizeof(char *); // For 'grent->gr_mem'.
42+
lssize = n * sizeof(char *); // For 'grent.gr_mem'.
4443
size = lssize + strlen(s) + 1;
4544

4645
free(buf);
4746
buf = MALLOC(size, char);
4847
if (buf == NULL)
4948
return NULL;
5049

51-
e = sgetgrent_r(s, grent, buf, size);
50+
e = sgetgrent_r(s, &grent, buf, size);
5251
if (e != 0) {
5352
errno = e;
5453
return NULL;
5554
}
5655

57-
return grent;
56+
return &grent;
5857
}
5958

6059

lib/shadow/gshadow/sgetsgent.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,28 @@ struct sgrp *
3232
sgetsgent(const char *s)
3333
{
3434
static char *buf = NULL;
35-
static struct sgrp sgent_ = {};
36-
struct sgrp *sgent = &sgent_;
35+
static struct sgrp sgent = {};
3736

3837
int e;
3938
size_t n, lssize, size;
4039
struct sgrp *dummy;
4140

4241
n = strchrcnt(s, ',') + 4;
43-
lssize = n * sizeof(char *); // For 'sgent->sg_adm' and 'sgent->sg_mem'
42+
lssize = n * sizeof(char *); // For 'sgent.sg_adm' and 'sgent.sg_mem'
4443
size = lssize + strlen(s) + 1;
4544

4645
free(buf);
4746
buf = MALLOC(size, char);
4847
if (buf == NULL)
4948
return NULL;
5049

51-
e = sgetsgent_r(s, sgent, buf, size, &dummy);
50+
e = sgetsgent_r(s, &sgent, buf, size, &dummy);
5251
if (e != 0) {
5352
errno = e;
5453
return NULL;
5554
}
5655

57-
return sgent;
56+
return &sgent;
5857
}
5958

6059

lib/shadow/passwd/sgetpwent.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ struct passwd *
3333
sgetpwent(const char *s)
3434
{
3535
static char *buf = NULL;
36-
static struct passwd pwent_ = {};
37-
struct passswd *pwent = &pwent_;
36+
static struct passwd pwent = {};
3837

3938
int e;
4039
size_t size;
@@ -46,13 +45,13 @@ sgetpwent(const char *s)
4645
if (buf == NULL)
4746
return NULL;
4847

49-
e = sgetpwent_r(s, pwent, buf, size);
48+
e = sgetpwent_r(s, &pwent, buf, size);
5049
if (e != 0) {
5150
errno = e;
5251
return NULL;
5352
}
5453

55-
return pwent;
54+
return &pwent;
5655
}
5756

5857

lib/shadow/shadow/sgetspent.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ struct spwd *
4040
sgetspent(const char *s)
4141
{
4242
static char *buf = NULL;
43-
static struct spwd spent_ = {};
44-
struct spwd *spent = &spent_;
43+
static struct spwd spent = {};
4544

4645
int e;
4746
size_t size;
@@ -54,13 +53,13 @@ sgetspent(const char *s)
5453
if (buf == NULL)
5554
return NULL;
5655

57-
e = sgetspent_r(s, spent, buf, size, &dummy);
56+
e = sgetspent_r(s, &spent, buf, size, &dummy);
5857
if (e != 0) {
5958
errno = e;
6059
return NULL;
6160
}
6261

63-
return spent;
62+
return &spent;
6463
}
6564
#endif
6665

lib/shadow/subid/sgetsient.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ struct subordinate_range *
2626
sgetsient(const char *s)
2727
{
2828
static char *buf = NULL;
29-
static struct subordinate_range sient_ = {};
30-
struct subordinate_range *sient = &sient_;
29+
static struct subordinate_range sient = {};
3130

3231
int e;
3332
size_t size;
@@ -39,13 +38,13 @@ sgetsient(const char *s)
3938
if (buf == NULL)
4039
return NULL;
4140

42-
e = sgetsient_r(s, sient, buf, size);
41+
e = sgetsient_r(s, &sient, buf, size);
4342
if (e != 0) {
4443
errno = e;
4544
return NULL;
4645
}
4746

48-
return sient;
47+
return &sient;
4948
}
5049

5150

0 commit comments

Comments
 (0)