chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6ec60d2
)
use more _cleanup_ macro
author
Ronny Chevalier
<chevalier.ronny@gmail.com>
Tue, 24 Jun 2014 17:00:32 +0000
(19:00 +0200)
committer
Tom Gundersen
<teg@jklm.no>
Tue, 24 Jun 2014 17:09:57 +0000
(19:09 +0200)
src/core/automount.c
patch
|
blob
|
history
src/core/execute.c
patch
|
blob
|
history
src/core/killall.c
patch
|
blob
|
history
src/core/umount.c
patch
|
blob
|
history
src/shared/conf-files.c
patch
|
blob
|
history
src/shared/fdset.c
patch
|
blob
|
history
src/shared/path-util.c
patch
|
blob
|
history
src/shared/util.c
patch
|
blob
|
history
diff --git
a/src/core/automount.c
b/src/core/automount.c
index 65e6d6f179219aba14996e61b9f59c226e9e021b..73a8ce17e4a7052e1e29c38cfdcb08696b7ac064 100644
(file)
--- a/
src/core/automount.c
+++ b/
src/core/automount.c
@@
-144,7
+144,7
@@
static int automount_add_default_dependencies(Automount *a) {
static int automount_verify(Automount *a) {
bool b;
static int automount_verify(Automount *a) {
bool b;
-
char *e
;
+
_cleanup_free_ char *e = NULL
;
assert(a);
if (UNIT(a)->load_state != UNIT_LOADED)
assert(a);
if (UNIT(a)->load_state != UNIT_LOADED)
@@
-160,7
+160,6
@@
static int automount_verify(Automount *a) {
return -ENOMEM;
b = unit_has_name(UNIT(a), e);
return -ENOMEM;
b = unit_has_name(UNIT(a), e);
- free(e);
if (!b) {
log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
if (!b) {
log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
diff --git
a/src/core/execute.c
b/src/core/execute.c
index 78fb81f7262771d97002512bb3e5ea964bfa0c67..1ea646334bce13edac6fb57567bc7a828fd77937 100644
(file)
--- a/
src/core/execute.c
+++ b/
src/core/execute.c
@@
-561,7
+561,7
@@
static int restore_confirm_stdio(int *saved_stdin,
static int ask_for_confirmation(char *response, char **argv) {
int saved_stdout = -1, saved_stdin = -1, r;
static int ask_for_confirmation(char *response, char **argv) {
int saved_stdout = -1, saved_stdin = -1, r;
-
char *line
;
+
_cleanup_free_ char *line = NULL
;
r = setup_confirm_stdio(&saved_stdin, &saved_stdout);
if (r < 0)
r = setup_confirm_stdio(&saved_stdin, &saved_stdout);
if (r < 0)
@@
-572,7
+572,6
@@
static int ask_for_confirmation(char *response, char **argv) {
return -ENOMEM;
r = ask(response, "yns", "Execute %s? [Yes, No, Skip] ", line);
return -ENOMEM;
r = ask(response, "yns", "Execute %s? [Yes, No, Skip] ", line);
- free(line);
restore_confirm_stdio(&saved_stdin, &saved_stdout);
restore_confirm_stdio(&saved_stdin, &saved_stdout);
@@
-2058,8
+2057,8
@@
int exec_context_load_environment(const ExecContext *c, char ***l) {
}
static bool tty_may_match_dev_console(const char *tty) {
}
static bool tty_may_match_dev_console(const char *tty) {
-
char *active = NULL, *console
;
-
bool b
;
+
_cleanup_free_ char *active = NULL
;
+
char *console
;
if (startswith(tty, "/dev/"))
tty += 5;
if (startswith(tty, "/dev/"))
tty += 5;
@@
-2074,10
+2073,7
@@
static bool tty_may_match_dev_console(const char *tty) {
return true;
/* "tty0" means the active VC, so it may be the same sometimes */
return true;
/* "tty0" means the active VC, so it may be the same sometimes */
- b = streq(console, tty) || (streq(console, "tty0") && tty_is_vc(tty));
- free(active);
-
- return b;
+ return streq(console, tty) || (streq(console, "tty0") && tty_is_vc(tty));
}
bool exec_context_may_touch_console(ExecContext *ec) {
}
bool exec_context_may_touch_console(ExecContext *ec) {
@@
-2467,10
+2463,10
@@
char *exec_command_line(char **argv) {
}
void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
}
void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
-
char *p2
;
+
_cleanup_free_ char *p2 = NULL
;
const char *prefix2;
const char *prefix2;
-
char *cmd
;
+
_cleanup_free_ char *cmd = NULL
;
assert(c);
assert(f);
assert(c);
assert(f);
@@
-2486,11
+2482,7
@@
void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
"%sCommand Line: %s\n",
prefix, cmd ? cmd : strerror(ENOMEM));
"%sCommand Line: %s\n",
prefix, cmd ? cmd : strerror(ENOMEM));
- free(cmd);
-
exec_status_dump(&c->exec_status, f, prefix2);
exec_status_dump(&c->exec_status, f, prefix2);
-
- free(p2);
}
void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
}
void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
diff --git
a/src/core/killall.c
b/src/core/killall.c
index eab48f7dcabdc9475a788b7bcd46256bb1ac614a..291e1f90eeb192be472f2faf876a04c4e0521093 100644
(file)
--- a/
src/core/killall.c
+++ b/
src/core/killall.c
@@
-202,7
+202,7
@@
static int killall(int sig, Set *pids, bool send_sighup) {
void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
sigset_t mask, oldmask;
void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
sigset_t mask, oldmask;
- Set *pids = NULL;
+
_cleanup_set_free_
Set *pids = NULL;
if (wait_for_exit)
pids = set_new(trivial_hash_func, trivial_compare_func);
if (wait_for_exit)
pids = set_new(trivial_hash_func, trivial_compare_func);
@@
-223,6
+223,4
@@
void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
wait_for_children(pids, &mask);
assert_se(sigprocmask(SIG_SETMASK, &oldmask, NULL) == 0);
wait_for_children(pids, &mask);
assert_se(sigprocmask(SIG_SETMASK, &oldmask, NULL) == 0);
-
- set_free(pids);
}
}
diff --git
a/src/core/umount.c
b/src/core/umount.c
index a30f6740fada15b5b00214ede9e2173b0517ffe4..cffa45327be531784ac64cc9864c82ff622e4fe4 100644
(file)
--- a/
src/core/umount.c
+++ b/
src/core/umount.c
@@
-126,9
+126,8
@@
static int mount_points_list_get(MountPoint **head) {
}
static int swap_list_get(MountPoint **head) {
}
static int swap_list_get(MountPoint **head) {
-
FILE *proc_swaps
;
+
_cleanup_fclose_ FILE *proc_swaps = NULL
;
unsigned int i;
unsigned int i;
- int r;
assert(head);
assert(head);
@@
-168,26
+167,19
@@
static int swap_list_get(MountPoint **head) {
free(dev);
if (!d) {
free(dev);
if (!d) {
- r = -ENOMEM;
- goto finish;
+ return -ENOMEM;
}
if (!(swap = new0(MountPoint, 1))) {
free(d);
}
if (!(swap = new0(MountPoint, 1))) {
free(d);
- r = -ENOMEM;
- goto finish;
+ return -ENOMEM;
}
swap->path = d;
LIST_PREPEND(mount_point, *head, swap);
}
}
swap->path = d;
LIST_PREPEND(mount_point, *head, swap);
}
- r = 0;
-
-finish:
- fclose(proc_swaps);
-
- return r;
+ return 0;
}
static int loopback_list_get(MountPoint **head) {
}
static int loopback_list_get(MountPoint **head) {
diff --git
a/src/shared/conf-files.c
b/src/shared/conf-files.c
index 64ce8a0e57fb70d4c90479b2d3f37528f45a3dfd..c72a099b5a1bb5b6805e2f11f651bab3ab1786e5 100644
(file)
--- a/
src/shared/conf-files.c
+++ b/
src/shared/conf-files.c
@@
-98,7
+98,7
@@
static int base_cmp(const void *a, const void *b) {
}
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const char *root, char **dirs) {
}
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const char *root, char **dirs) {
-
Hashmap *fh
;
+
_cleanup_hashmap_free_ Hashmap *fh = NULL
;
char **files, **p;
int r;
char **files, **p;
int r;
@@
-116,7
+116,6
@@
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
STRV_FOREACH(p, dirs) {
r = files_add(fh, root, *p, suffix);
if (r == -ENOMEM) {
STRV_FOREACH(p, dirs) {
r = files_add(fh, root, *p, suffix);
if (r == -ENOMEM) {
- hashmap_free_free(fh);
return r;
} else if (r < 0)
log_debug("Failed to search for files in %s: %s",
return r;
} else if (r < 0)
log_debug("Failed to search for files in %s: %s",
@@
-125,14
+124,12
@@
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
files = hashmap_get_strv(fh);
if (files == NULL) {
files = hashmap_get_strv(fh);
if (files == NULL) {
- hashmap_free_free(fh);
return -ENOMEM;
}
qsort_safe(files, hashmap_size(fh), sizeof(char *), base_cmp);
*strv = files;
return -ENOMEM;
}
qsort_safe(files, hashmap_size(fh), sizeof(char *), base_cmp);
*strv = files;
- hashmap_free(fh);
return 0;
}
return 0;
}
diff --git
a/src/shared/fdset.c
b/src/shared/fdset.c
index a2c861de3f4b0486f7fbb742e717237555b16c09..d2ea665016b54b49f48d8496af7fa96911560723 100644
(file)
--- a/
src/shared/fdset.c
+++ b/
src/shared/fdset.c
@@
-104,7
+104,7
@@
int fdset_remove(FDSet *s, int fd) {
}
int fdset_new_fill(FDSet **_s) {
}
int fdset_new_fill(FDSet **_s) {
-
DIR *d
;
+
_cleanup_closedir_ DIR *d = NULL
;
struct dirent *de;
int r = 0;
FDSet *s;
struct dirent *de;
int r = 0;
FDSet *s;
@@
-150,8
+150,6
@@
int fdset_new_fill(FDSet **_s) {
s = NULL;
finish:
s = NULL;
finish:
- closedir(d);
-
/* We won't close the fds here! */
if (s)
set_free(MAKE_SET(s));
/* We won't close the fds here! */
if (s)
set_free(MAKE_SET(s));
diff --git
a/src/shared/path-util.c
b/src/shared/path-util.c
index d193494afb266b94d771d2fc44128c45c47f7e4d..fd35e0c78671773b19583296bd52433a91968879 100644
(file)
--- a/
src/shared/path-util.c
+++ b/
src/shared/path-util.c
@@
-442,7
+442,7
@@
int path_is_mount_point(const char *t, bool allow_symlink) {
};
int mount_id, mount_id_parent;
};
int mount_id, mount_id_parent;
-
char *parent
;
+
_cleanup_free_ char *parent = NULL
;
struct stat a, b;
int r;
struct stat a, b;
int r;
@@
-473,7
+473,6
@@
int path_is_mount_point(const char *t, bool allow_symlink) {
h.handle.handle_bytes = MAX_HANDLE_SZ;
r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, 0);
h.handle.handle_bytes = MAX_HANDLE_SZ;
r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, 0);
- free(parent);
if (r < 0) {
/* The parent can't do name_to_handle_at() but the
* directory we are interested in can? If so, it must
if (r < 0) {
/* The parent can't do name_to_handle_at() but the
* directory we are interested in can? If so, it must
@@
-504,7
+503,6
@@
fallback:
return r;
r = lstat(parent, &b);
return r;
r = lstat(parent, &b);
- free(parent);
if (r < 0)
return -errno;
if (r < 0)
return -errno;
diff --git
a/src/shared/util.c
b/src/shared/util.c
index dbdb69270de7a7db7163397ff5df9a2e08f4ef17..e7ff0f8840fdbe5d85c82e0c55d0367a4833c2b7 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-1440,7
+1440,7
@@
_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) {
}
int close_all_fds(const int except[], unsigned n_except) {
}
int close_all_fds(const int except[], unsigned n_except) {
-
DIR *d
;
+
_cleanup_closedir_ DIR *d = NULL
;
struct dirent *de;
int r = 0;
struct dirent *de;
int r = 0;
@@
-1495,7
+1495,6
@@
int close_all_fds(const int except[], unsigned n_except) {
}
}
}
}
- closedir(d);
return r;
}
return r;
}