chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] rework the logging code so that each program logs with the proper name in...
[elogind.git]
/
namedev.c
diff --git
a/namedev.c
b/namedev.c
index 6b1aa297eae222b5736147301d5af211ec2b6d40..6685596479ac14102246ab40c555b51886ceb303 100644
(file)
--- a/
namedev.c
+++ b/
namedev.c
@@
-47,34
+47,35
@@
LIST_HEAD(perm_device_list);
/* compare string with pattern (supports * ? [0-9] [!A-Z]) */
static int strcmp_pattern(const char *p, const char *s)
{
/* compare string with pattern (supports * ? [0-9] [!A-Z]) */
static int strcmp_pattern(const char *p, const char *s)
{
- if (
*s
== '\0') {
- while (
*p
== '*')
+ if (
s[0]
== '\0') {
+ while (
p[0]
== '*')
p++;
p++;
- return (
*p
!= '\0');
+ return (
p[0]
!= '\0');
}
}
- switch (
*p
) {
+ switch (
p[0]
) {
case '[':
{
int not = 0;
p++;
case '[':
{
int not = 0;
p++;
- if (
*p
== '!') {
+ if (
p[0]
== '!') {
not = 1;
p++;
}
not = 1;
p++;
}
- while (
*p && (*p
!= ']')) {
+ while (
(p[0] != '\0') && (p[0]
!= ']')) {
int match = 0;
if (p[1] == '-') {
int match = 0;
if (p[1] == '-') {
- if ((
*s >= *p) && (*s
<= p[2]))
+ if ((
s[0] >= p[0]) && (s[0]
<= p[2]))
match = 1;
p += 3;
} else {
match = 1;
p += 3;
} else {
- match = (
*p == *s
);
+ match = (
p[0] == s[0]
);
p++;
}
if (match ^ not) {
p++;
}
if (match ^ not) {
- while (
*p && (*p
!= ']'))
+ while (
(p[0] != '\0') && (p[0]
!= ']'))
p++;
p++;
- return strcmp_pattern(p+1, s+1);
+ if (p[0] == ']')
+ return strcmp_pattern(p+1, s+1);
}
}
}
}
}
}
@@
-84,12
+85,12
@@
static int strcmp_pattern(const char *p, const char *s)
return strcmp_pattern(p+1, s);
return 0;
case '\0':
return strcmp_pattern(p+1, s);
return 0;
case '\0':
- if (
*s
== '\0') {
+ if (
s[0]
== '\0') {
return 0;
}
break;
default:
return 0;
}
break;
default:
- if ((
*p == *s) || (*p
== '?'))
+ if ((
p[0] == s[0]) || (p[0]
== '?'))
return strcmp_pattern(p+1, s+1);
break;
}
return strcmp_pattern(p+1, s+1);
break;
}
@@
-332,12
+333,8
@@
static int execute_program(char *path, char *value, int len)
return -1;
}
pid = fork();
return -1;
}
pid = fork();
- if (pid == -1) {
- dbg("fork failed");
- return -1;
- }
-
- if (pid == 0) {
+ switch(pid) {
+ case 0:
/* child */
close(STDOUT_FILENO);
dup(fds[1]); /* dup write side of pipe to STDOUT */
/* child */
close(STDOUT_FILENO);
dup(fds[1]); /* dup write side of pipe to STDOUT */
@@
-353,16
+350,16
@@
static int execute_program(char *path, char *value, int len)
dbg("too many args - %d", i);
args[i] = NULL;
}
dbg("too many args - %d", i);
args[i] = NULL;
}
- retval = execv
e(args[0], args, main_envp
);
+ retval = execv
(args[0], args
);
} else {
} else {
- retval = execve(path, main_argv, main_envp);
- }
- if (retval != 0) {
- dbg("child execve failed");
- exit(1);
+ retval = execv(path, main_argv);
}
}
- return -1; /* avoid compiler warning */
- } else {
+ dbg("child execve failed");
+ exit(1);
+ case -1:
+ dbg("fork failed");
+ return -1;
+ default:
/* parent reads from fds[0] */
close(fds[1]);
retval = 0;
/* parent reads from fds[0] */
close(fds[1]);
retval = 0;