summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9bfa2c0)
https://bugzilla.redhat.com/show_bug.cgi?id=
1043304
static struct node *bus_node_allocate(sd_bus *bus, const char *path) {
struct node *n, *parent;
const char *e;
static struct node *bus_node_allocate(sd_bus *bus, const char *path) {
struct node *n, *parent;
const char *e;
+ _cleanup_free_ char *s = NULL;
+ char *p;
p = strndupa(path, MAX(1, path - e));
parent = bus_node_allocate(bus, p);
p = strndupa(path, MAX(1, path - e));
parent = bus_node_allocate(bus, p);
- if (!parent) {
- free(s);
}
n = new0(struct node, 1);
}
n = new0(struct node, 1);
n->parent = parent;
n->path = s;
n->parent = parent;
n->path = s;
+ s = NULL; /* do not free */
r = hashmap_put(bus->nodes, s, n);
if (r < 0) {
r = hashmap_put(bus->nodes, s, n);
if (r < 0) {
-static int write_state(FILE *f0, char **states) {
- FILE _cleanup_fclose_ *f = f0;
+static int write_state(FILE **f, char **states) {
char **state;
int r = 0;
STRV_FOREACH(state, states) {
int k;
char **state;
int r = 0;
STRV_FOREACH(state, states) {
int k;
- k = write_string_to_file(f, *state);
+ k = write_string_to_file(*f, *state);
if (k == 0)
return 0;
log_debug("Failed to write '%s' to /sys/power/state: %s",
if (k == 0)
return 0;
log_debug("Failed to write '%s' to /sys/power/state: %s",
- fclose(f);
- f = fopen("/sys/power/state", "we");
- if (!f) {
+ fclose(*f);
+ *f = fopen("/sys/power/state", "we");
+ if (!*f) {
log_error("Failed to open /sys/power/state: %m");
return -errno;
}
log_error("Failed to open /sys/power/state: %m");
return -errno;
}
static int execute(char **modes, char **states) {
char* arguments[4];
int r;
static int execute(char **modes, char **states) {
char* arguments[4];
int r;
+ _cleanup_fclose_ FILE *f = NULL;
const char* note = strappenda("SLEEP=", arg_verb);
/* This file is opened first, so that if we hit an error,
const char* note = strappenda("SLEEP=", arg_verb);
/* This file is opened first, so that if we hit an error,
- r = write_state(f, states);
+ r = write_state(&f, states);
static int load_link(link_config_ctx *ctx, const char *filename) {
link_config *link;
static int load_link(link_config_ctx *ctx, const char *filename) {
link_config *link;
+ _cleanup_fclose_ FILE *file;
int r;
file = fopen(filename, "re");
int r;
file = fopen(filename, "re");