aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-06-20 09:56:47 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-06-20 09:56:47 +0000
commitbb0baed564489c678204a54d97cee9d57a4a1189 (patch)
tree8027fd51be4256f9d98a7f5298ef53b9beab85f9 /util-linux/mdev.c
parentbb98db2ed2140db5fd5c08112e257ed864aec646 (diff)
downloadbusybox-w32-bb0baed564489c678204a54d97cee9d57a4a1189.tar.gz
busybox-w32-bb0baed564489c678204a54d97cee9d57a4a1189.tar.bz2
busybox-w32-bb0baed564489c678204a54d97cee9d57a4a1189.zip
- strndupa is a GNU extension. Using strdup to avoid several errors like:
util-linux/mdev.c:(.text+0x29a): undefined reference to `strndupa'
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r--util-linux/mdev.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 8743cdb6b..22005aaee 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -90,7 +90,7 @@ static void make_device(char *path, int delete)
90 if (field == 0) { 90 if (field == 0) {
91 /* Regex to match this device */ 91 /* Regex to match this device */
92 92
93 char *regex = strndupa(pos, end2-pos); 93 char *regex = xstrndup(pos, end2-pos);
94 regex_t match; 94 regex_t match;
95 regmatch_t off; 95 regmatch_t off;
96 int result; 96 int result;
@@ -99,6 +99,7 @@ static void make_device(char *path, int delete)
99 xregcomp(&match,regex, REG_EXTENDED); 99 xregcomp(&match,regex, REG_EXTENDED);
100 result = regexec(&match, device_name, 1, &off, 0); 100 result = regexec(&match, device_name, 1, &off, 0);
101 regfree(&match); 101 regfree(&match);
102 free(regex);
102 103
103 /* If not this device, skip rest of line */ 104 /* If not this device, skip rest of line */
104 if (result || off.rm_so 105 if (result || off.rm_so
@@ -119,7 +120,9 @@ static void make_device(char *path, int delete)
119 uid = strtoul(pos, &s2, 10); 120 uid = strtoul(pos, &s2, 10);
120 if (s != s2) { 121 if (s != s2) {
121 struct passwd *pass; 122 struct passwd *pass;
122 pass = getpwnam(strndupa(pos, s-pos)); 123 char *_unam = xstrndup(pos, s-pos);
124 pass = getpwnam(_unam);
125 free(_unam);
123 if (!pass) break; 126 if (!pass) break;
124 uid = pass->pw_uid; 127 uid = pass->pw_uid;
125 } 128 }
@@ -128,7 +131,9 @@ static void make_device(char *path, int delete)
128 gid = strtoul(s, &s2, 10); 131 gid = strtoul(s, &s2, 10);
129 if (end2 != s2) { 132 if (end2 != s2) {
130 struct group *grp; 133 struct group *grp;
131 grp = getgrnam(strndupa(s, end2-s)); 134 char *_grnam = xstrndup(s, end2-s);
135 grp = getgrnam(_grnam);
136 free(_grnam);
132 if (!grp) break; 137 if (!grp) break;
133 gid = grp->gr_gid; 138 gid = grp->gr_gid;
134 } 139 }