Skip to content

Commit ab412ac

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 2efa2d3 commit ab412ac

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
@@ -34,28 +34,27 @@ struct sgrp *
3434
sgetsgent(const char *s)
3535
{
3636
static char *buf = NULL;
37-
static struct sgrp sgent_ = {};
38-
struct sgrp *sgent = &sgent_;
37+
static struct sgrp sgent = {};
3938

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

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

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

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

58-
return sgent;
57+
return &sgent;
5958
}
6059

6160

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
@@ -38,8 +38,7 @@ struct spwd *
3838
sgetspent(const char *s)
3939
{
4040
static char *buf = NULL;
41-
static struct spwd spent_ = {};
42-
struct spwd *spent = &spent_;
41+
static struct spwd spent = {};
4342

4443
int e;
4544
size_t size;
@@ -51,13 +50,13 @@ sgetspent(const char *s)
5150
if (buf == NULL)
5251
return NULL;
5352

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

60-
return spent;
59+
return &spent;
6160
}
6261
#endif
6362

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)