Skip to content

Commit 2d1b76a

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 c69d205 commit 2d1b76a

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
@@ -35,29 +35,28 @@ struct sgrp *
3535
sgetsgent(const char *s)
3636
{
3737
static char *buf = NULL;
38-
static struct sgrp sgent_ = {};
39-
struct sgrp *sgent = &sgent_;
38+
static struct sgrp sgent = {};
4039

4140
int e;
4241
size_t n, lssize, size;
4342
struct sgrp *dummy;
4443

4544
n = strchrcnt(s, ',') + 4;
46-
lssize = n * sizeof(char *); // For 'sgent->sg_adm' and 'sgent->sg_mem'
45+
lssize = n * sizeof(char *); // For 'sgent.sg_adm' and 'sgent.sg_mem'
4746
size = lssize + strlen(s) + 1;
4847

4948
free(buf);
5049
buf = MALLOC(size, char);
5150
if (buf == NULL)
5251
return NULL;
5352

54-
e = sgetsgent_r(s, sgent, buf, size, &dummy);
53+
e = sgetsgent_r(s, &sgent, buf, size, &dummy);
5554
if (e != 0) {
5655
errno = e;
5756
return NULL;
5857
}
5958

60-
return sgent;
59+
return &sgent;
6160
}
6261

6362

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
@@ -41,8 +41,7 @@ struct spwd *
4141
sgetspent(const char *s)
4242
{
4343
static char *buf = NULL;
44-
static struct spwd spent_ = {};
45-
struct spwd *spent = &spent_;
44+
static struct spwd spent = {};
4645

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

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

64-
return spent;
63+
return &spent;
6564
}
6665
#endif
6766

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)