smdev

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

commit 0c13b2cf9547db0e94825c1343a98eaea5e7b13a
parent 9ef2984829ef5c3655296ceed54d270fbff660cc
Author: sin <sin@2f30.org>
Date:   Mon,  2 Sep 2013 10:38:23 +0100

Constify struct rule in config.h

Diffstat:
Mconfig.h | 10+++++-----
Msmdev.c | 7++++++-
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/config.h b/config.h @@ -1,11 +1,11 @@ /* See LICENSE file for copyright and license details. */ struct rule { - char *devregex; - char *user; - char *group; + const char *devregex; + const char *user; + const char *group; int mode; - char *path; - char *cmd; + const char *path; + const char *cmd; } rules[] = { { "null", "root", "root", 0666, NULL, "@chmod 666 $SMDEV" }, { "zero", "root", "root", 0666, NULL, NULL }, diff --git a/smdev.c b/smdev.c @@ -180,13 +180,16 @@ parsepath(struct rule *rule, struct rulepath *rpath, if (rule->path[0] != '=' && rule->path[0] != '>') eprintf("Invalid path '%s'\n", rule->path); - path = &rule->path[1]; + path = strdup(&rule->path[1]); + if (!path) + eprintf("strdup:"); /* No need to rename the device node */ if (rule->path[strlen(rule->path) - 1] == '/') { snprintf(rpath->path, sizeof(rpath->path), "/dev/%s%s", path, devname); strlcpy(rpath->name, devname, sizeof(rpath->name)); + free(path); return; } @@ -203,6 +206,8 @@ parsepath(struct rule *rule, struct rulepath *rpath, snprintf(rpath->path, sizeof(rpath->path), "/dev/%s", rpath->name); } + + free(path); } static int