chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: make use of isempty() where appropriate
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index d33f349d816d9a667b236e420609c6e519d2de37..dc1bc39ac710b50f4f52cd171674bd053d3b20ae 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-695,7
+695,7
@@
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
}
/* Kernel threads have no argv[] */
}
/* Kernel threads have no argv[] */
- if (
r == NULL || r[0] == 0
) {
+ if (
isempty(r)
) {
_cleanup_free_ char *t = NULL;
int h;
_cleanup_free_ char *t = NULL;
int h;
@@
-6987,14
+6987,14
@@
int is_symlink(const char *path) {
int is_dir(const char* path, bool follow) {
struct stat st;
int is_dir(const char* path, bool follow) {
struct stat st;
+ int r;
- if (follow) {
- if (stat(path, &st) < 0)
- return -errno;
- } else {
- if (lstat(path, &st) < 0)
- return -errno;
- }
+ if (follow)
+ r = stat(path, &st);
+ else
+ r = lstat(path, &st);
+ if (r < 0)
+ return -errno;
return !!S_ISDIR(st.st_mode);
}
return !!S_ISDIR(st.st_mode);
}