sd-dhcp-client: Add missing initializers

Missing initializers together with automatic cleanup seem to annoy GCC's
-Werror=maybe-uninitialized, breaking the --enable-more-warnings=error
builds.
This commit is contained in:
Lubomir Rintel 2014-11-07 11:47:19 +01:00
parent 3a551664df
commit b1550df6f5
6 changed files with 12 additions and 16 deletions

View file

@ -397,7 +397,7 @@ static void client_stop(sd_dhcp_client *client, int error) {
static int client_message_init(sd_dhcp_client *client, DHCPPacket **ret,
uint8_t type, size_t *_optlen, size_t *_optoffset) {
_cleanup_free_ DHCPPacket *packet;
_cleanup_free_ DHCPPacket *packet = NULL;
size_t optlen, optoffset, size;
be16_t max_size;
usec_t time_now;

View file

@ -687,7 +687,7 @@ int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
r = sd_dhcp_lease_get_client_id(lease, &client_id, &client_id_len);
if (r >= 0) {
_cleanup_free_ char *client_id_hex;
_cleanup_free_ char *client_id_hex = NULL;
client_id_hex = hexmem (client_id, client_id_len);
if (!client_id_hex) {

View file

@ -844,7 +844,7 @@ static int client_receive_message(sd_event_source *s, int fd, uint32_t revents,
void *userdata) {
sd_dhcp6_client *client = userdata;
DHCP6_CLIENT_DONT_DESTROY(client);
_cleanup_free_ DHCP6Message *message;
_cleanup_free_ DHCP6Message *message = NULL;
int r, buflen, len;
assert(s);

View file

@ -145,7 +145,7 @@ int read_one_line_file(const char *fn, char **line) {
}
ssize_t sendfile_full(int out_fd, const char *fn) {
_cleanup_fclose_ FILE *f;
_cleanup_fclose_ FILE *f = NULL;
struct stat st;
int r;
ssize_t s;
@ -589,17 +589,15 @@ static int parse_env_file_push(
va_list aq, *ap = userdata;
if (!utf8_is_valid(key)) {
_cleanup_free_ char *p;
_cleanup_free_ char *p = utf8_escape_invalid(key);
p = utf8_escape_invalid(key);
log_error("%s:%u: invalid UTF-8 in key '%s', ignoring.", strna(filename), line, p);
return -EINVAL;
}
if (value && !utf8_is_valid(value)) {
_cleanup_free_ char *p;
_cleanup_free_ char *p = utf8_escape_invalid(value);
p = utf8_escape_invalid(value);
log_error("%s:%u: invalid UTF-8 value for key %s: '%s', ignoring.", strna(filename), line, key, p);
return -EINVAL;
}

View file

@ -507,9 +507,8 @@ int parse_timestamp(const char *t, usec_t *usec) {
return parse_sec(t + 1, usec);
else if (endswith(t, " ago")) {
_cleanup_free_ char *z;
_cleanup_free_ char *z = strndup(t, strlen(t) - 4);
z = strndup(t, strlen(t) - 4);
if (!z)
return -ENOMEM;
@ -519,9 +518,8 @@ int parse_timestamp(const char *t, usec_t *usec) {
goto finish;
} else if (endswith(t, " left")) {
_cleanup_free_ char *z;
_cleanup_free_ char *z = strndup(t, strlen(t) - 4);
z = strndup(t, strlen(t) - 4);
if (!z)
return -ENOMEM;

View file

@ -1619,7 +1619,7 @@ bool fstype_is_network(const char *fstype) {
}
int chvt(int vt) {
_cleanup_close_ int fd;
_cleanup_close_ int fd = -1;
fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
@ -2490,7 +2490,7 @@ char* dirname_malloc(const char *path) {
#endif
int dev_urandom(void *p, size_t n) {
_cleanup_close_ int fd;
_cleanup_close_ int fd = -1;
ssize_t k;
fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC|O_NOCTTY);
@ -3492,7 +3492,7 @@ char *ellipsize(const char *s, size_t length, unsigned percent) {
}
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) {
_cleanup_close_ int fd;
_cleanup_close_ int fd = -1;
int r;
assert(path);
@ -4214,7 +4214,7 @@ int terminal_vhangup_fd(int fd) {
}
int terminal_vhangup(const char *name) {
_cleanup_close_ int fd;
_cleanup_close_ int fd = -1;
fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)