smdev

suckless mdev
git clone git://git.suckless.org/smdev
Log | Files | Refs | README | LICENSE

commit c228339545934e7ddf3f25ad262348488a36c01c
parent 8ded4053dbc591e4027f0e57b132fdead3ed35b5
Author: sin <sin@2f30.org>
Date:   Fri, 23 Aug 2013 14:54:21 +0100

Use path for &rule->path[1]

Diffstat:
Msmdev.c | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/smdev.c b/smdev.c @@ -166,30 +166,31 @@ static void parsepath(struct rule *rule, char *devpath, size_t devpathsz, char *devname, size_t devnamesz) { - char buf[BUFSIZ], *p; + char buf[BUFSIZ], *p, *path; char *dirc; if (rule->path[0] != '=' && rule->path[0] != '>') eprintf("Invalid path '%s'\n", rule->path); + path = &rule->path[1]; + /* No need to rename the device node */ if (rule->path[strlen(rule->path) - 1] == '/') { snprintf(devpath, devpathsz, "/dev/%s%s", - &rule->path[1], devname); + path, devname); return; } - p = strchr(&rule->path[1], '/'); + p = strchr(path, '/'); if (p) { - if (!(dirc = strdup(&rule->path[1]))) + if (!(dirc = strdup(path))) eprintf("strdup:"); snprintf(buf, sizeof(buf), "/dev/%s", dirname(dirc)); - strlcpy(devname, basename(&rule->path[1]), devnamesz); - snprintf(devpath, devpathsz, "%s/%s", - buf, devname); + strlcpy(devname, basename(path), devnamesz); + snprintf(devpath, devpathsz, "%s/%s", buf, devname); free(dirc); } else { - strlcpy(devname, &rule->path[1], devnamesz); + strlcpy(devname, path, devnamesz); snprintf(devpath, devpathsz, "/dev/%s", devname); } }