mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
Fix Coverity warning for unchecked return value from dirname()
- Check return value from dirname() - Remove static from local compose buffer Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
d58c58d972
commit
caff08f58d
1 file changed
+10
-4
@@ -9,22 +9,28 @@
|
|||||||
|
|
||||||
int cond_set_path(const char *path, enum cond_state new)
|
int cond_set_path(const char *path, enum cond_state new)
|
||||||
{
|
{
|
||||||
static char dir[MAX_ARG_LEN];
|
char buf[MAX_ARG_LEN], *dir;
|
||||||
|
|
||||||
enum cond_state old;
|
enum cond_state old;
|
||||||
|
|
||||||
old = cond_get_path(path);
|
old = cond_get_path(path);
|
||||||
|
|
||||||
switch (new) {
|
switch (new) {
|
||||||
case COND_ON:
|
case COND_ON:
|
||||||
strlcpy(dir, path, sizeof(dir));
|
strlcpy(buf, path, sizeof(buf));
|
||||||
makepath(dirname(dir));
|
dir = dirname(buf);
|
||||||
|
if (!dir) {
|
||||||
|
_e("Invalid path '%s' for condition", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
makepath(dir);
|
||||||
touch(path);
|
touch(path);
|
||||||
utime(path, NULL);
|
utime(path, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COND_OFF:
|
case COND_OFF:
|
||||||
unlink(path);
|
unlink(path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_e("Invalid condition state");
|
_e("Invalid condition state");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user