[systemd-devel] [PATCH 1/2] Moving null check for strv_path_canonicalize inside function.
Luis Felipe Strano Moraes
luis.strano at gmail.com
Thu Sep 16 19:30:00 PDT 2010
Removes the need for the caller to check that, and has the added benefit
of avoiding a possible null dereference if caller wasn't careful.
---
src/path-lookup.c | 15 ++++++---------
src/util.c | 4 +++-
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/path-lookup.c b/src/path-lookup.c
index 28336eb..a0644a1 100644
--- a/src/path-lookup.c
+++ b/src/path-lookup.c
@@ -221,17 +221,14 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
}
}
- if (p->unit_path)
- if (!strv_path_canonicalize(p->unit_path))
- return -ENOMEM;
+ if (!strv_path_canonicalize(p->unit_path))
+ return -ENOMEM;
- if (p->sysvinit_path)
- if (!strv_path_canonicalize(p->sysvinit_path))
- return -ENOMEM;
+ if (!strv_path_canonicalize(p->sysvinit_path))
+ return -ENOMEM;
- if (p->sysvrcnd_path)
- if (!strv_path_canonicalize(p->sysvrcnd_path))
- return -ENOMEM;
+ if (!strv_path_canonicalize(p->sysvrcnd_path))
+ return -ENOMEM;
strv_uniq(p->unit_path);
strv_uniq(p->sysvinit_path);
diff --git a/src/util.c b/src/util.c
index bdc194e..e9ff11b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -986,7 +986,9 @@ char **strv_path_canonicalize(char **l) {
unsigned k = 0;
bool enomem = false;
- if (strv_isempty(l))
+ if (!l)
+ return true;
+ else if (strv_isempty(l))
return l;
/* Goes through every item in the string list and canonicalize
--
1.7.2.3
More information about the systemd-devel
mailing list