[systemd-commits] 2 commits - src/import src/journal src/journal-remote src/libsystemd src/libsystemd-network src/network src/resolve src/shared src/test src/udev
Harald Hoyer
harald at kemper.freedesktop.org
Fri Mar 27 06:57:45 PDT 2015
src/import/pull-job.c | 2 +-
src/journal-remote/journal-gatewayd.c | 2 +-
src/journal-remote/journal-remote-parse.c | 2 +-
src/journal-remote/journal-remote.c | 4 ++--
src/journal/catalog.c | 2 +-
src/journal/coredump.c | 4 ++--
src/journal/journal-file.c | 6 +++---
src/journal/journal-vacuum.c | 2 +-
src/journal/journalctl.c | 2 +-
src/journal/test-journal-stream.c | 2 +-
src/libsystemd-network/lldp-tlv.c | 8 ++++----
src/libsystemd-network/sd-dhcp-server.c | 2 +-
src/libsystemd-network/sd-pppoe.c | 2 +-
src/libsystemd/sd-login/sd-login.c | 2 +-
src/network/networkctl.c | 2 +-
src/resolve/resolved-dns-transaction.c | 2 +-
src/resolve/test-dns-domain.c | 2 +-
src/shared/base-filesystem.c | 2 +-
src/shared/btrfs-util.c | 2 +-
src/shared/capability.c | 2 +-
src/shared/copy.c | 6 +++---
src/shared/install.c | 2 +-
src/shared/logs-show.c | 2 +-
src/shared/util.c | 4 ++--
src/test/test-path.c | 2 +-
src/test/test-pty.c | 2 +-
src/udev/cdrom_id/cdrom_id.c | 27 ++++++++++++++-------------
src/udev/net/link-config.c | 2 +-
28 files changed, 51 insertions(+), 50 deletions(-)
New commits:
commit cb80d06c74ac6ba52fbfba8ecf5d5b2f06ba8c77
Author: Harald Hoyer <harald at redhat.com>
Date: Fri Mar 27 13:47:32 2015 +0100
cdrom_id: unroll and simplify data check loop
also removes this warning:
src/udev/cdrom_id/cdrom_id.c: In function ‘cd_media_info.isra.13’:
src/udev/cdrom_id/cdrom_id.c:612:12: warning: assuming signed overflow
does not occur when assuming that (X + c) >= X is always true
[-Wstrict-overflow]
static int cd_media_info(struct udev *udev, int fd)
^
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index 6052f6a..54a5075 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -650,8 +650,8 @@ static int cd_media_info(struct udev *udev, int fd)
* write protected; we need to check the contents if it is blank */
if ((cd_media_dvd_rw_ro || cd_media_dvd_plus_rw || cd_media_dvd_plus_rw_dl || cd_media_dvd_ram) && (header[2] & 3) > 1) {
unsigned char buffer[32 * 2048];
- unsigned char result, len;
- int block, offset;
+ unsigned char len;
+ int offset;
if (cd_media_dvd_ram) {
/* a write protected dvd-ram may report "complete" status */
@@ -732,22 +732,23 @@ static int cd_media_info(struct udev *udev, int fd)
/* if any non-zero data is found in sector 16 (iso and udf) or
* eventually 0 (fat32 boot sector, ext2 superblock, etc), disc
* is assumed non-blank */
- result = 0;
- for (block = 32768; block >= 0 && !result; block -= 32768) {
- offset = block;
- while (offset < (block + 2048) && !result) {
- result = buffer [offset];
- offset++;
+ for (offset = 32768; offset < (32768 + 2048); offset++) {
+ if (buffer [offset]) {
+ log_debug("data in block 16, assuming complete");
+ goto determined;
}
}
- if (!result) {
- cd_media_state = media_status[0];
- log_debug("no data in blocks 0 or 16, assuming blank");
- } else {
- log_debug("data in blocks 0 or 16, assuming complete");
+ for (offset = 0; offset < 2048; offset++) {
+ if (buffer [offset]) {
+ log_debug("data in block 0, assuming complete");
+ goto determined;
+ }
}
+
+ cd_media_state = media_status[0];
+ log_debug("no data in blocks 0 or 16, assuming blank");
}
determined:
commit a7f7d1bde43fc825c49afea3f946f5b4b3d563e0
Author: Harald Hoyer <harald at redhat.com>
Date: Fri Mar 27 12:02:49 2015 +0100
fix gcc warnings about uninitialized variables
like:
src/shared/install.c: In function ‘unit_file_lookup_state’:
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
return r < 0 ? r : state;
^
src/shared/install.c:1796:13: note: ‘r’ was declared here
int r;
^
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index ed9af23..42939f2 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -76,7 +76,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
long status;
int r;
- if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, &j) != CURLE_OK)
+ if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, (char **)&j) != CURLE_OK)
return;
if (!j || j->state == PULL_JOB_DONE || j->state == PULL_JOB_FAILED)
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index 6efc9b3..bba0d12 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -748,7 +748,7 @@ static int request_handler_machine(
RequestMeta *m = connection_cls;
int r;
_cleanup_free_ char* hostname = NULL, *os_name = NULL;
- uint64_t cutoff_from = 0, cutoff_to = 0, usage;
+ uint64_t cutoff_from = 0, cutoff_to = 0, usage = 0;
char *json;
sd_id128_t mid, bid;
_cleanup_free_ char *v = NULL;
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
index e8442d3..5ff05d3 100644
--- a/src/journal-remote/journal-remote-parse.c
+++ b/src/journal-remote/journal-remote-parse.c
@@ -321,7 +321,7 @@ static int process_data(RemoteSource *source) {
switch(source->state) {
case STATE_LINE: {
char *line, *sep;
- size_t n;
+ size_t n = 0;
assert(source->data_size == 0);
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 6198a99..f87a939 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -349,7 +349,7 @@ static int remove_source(RemoteServer *s, int fd) {
static int add_source(RemoteServer *s, int fd, char* name, bool own_name) {
- RemoteSource *source;
+ RemoteSource *source = NULL;
int r;
/* This takes ownership of name, even on failure, if own_name is true. */
@@ -1144,7 +1144,7 @@ static int dispatch_raw_connection_event(sd_event_source *event,
.size = sizeof(union sockaddr_union),
.type = SOCK_STREAM,
};
- char *hostname;
+ char *hostname = NULL;
fd2 = accept_connection("raw", fd, &addr, &hostname);
if (fd2 < 0)
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index e505a05..0801e13 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -558,7 +558,7 @@ static const char *find_id(void *p, sd_id128_t id) {
int catalog_get(const char* database, sd_id128_t id, char **_text) {
_cleanup_close_ int fd = -1;
void *p = NULL;
- struct stat st;
+ struct stat st = {};
char *text = NULL;
int r;
const char *s;
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 6357d3e..4e23e48 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -242,7 +242,7 @@ static int maybe_remove_external_coredump(const char *filename, off_t size) {
static int make_filename(const char *info[_INFO_LEN], char **ret) {
_cleanup_free_ char *c = NULL, *u = NULL, *p = NULL, *t = NULL;
- sd_id128_t boot;
+ sd_id128_t boot = {};
int r;
assert(info);
@@ -841,7 +841,7 @@ log:
/* Optionally store the entire coredump in the journal */
if (IN_SET(arg_storage, COREDUMP_STORAGE_JOURNAL, COREDUMP_STORAGE_BOTH) &&
coredump_size <= (off_t) arg_journal_size_max) {
- size_t sz;
+ size_t sz = 0;
/* Store the coredump itself in the journal */
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 8e76427..5a4e7cb 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -887,7 +887,7 @@ int journal_file_find_data_object_with_hash(
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
uint64_t l;
- size_t rsize;
+ size_t rsize = 0;
l = le64toh(o->object.size);
if (l <= offsetof(Object, data.payload))
@@ -1052,7 +1052,7 @@ static int journal_file_append_data(
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
if (f->compress_xz &&
size >= COMPRESSION_SIZE_THRESHOLD) {
- size_t rsize;
+ size_t rsize = 0;
compression = compress_blob(data, size, o->data.payload, &rsize);
@@ -2886,7 +2886,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
- size_t rsize;
+ size_t rsize = 0;
r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK,
o->data.payload, l, &from->compress_buffer, &from->compress_buffer_size, &rsize, 0);
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index a367dc1..81a577e 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -73,7 +73,7 @@ static void patch_realtime(
unsigned long long *realtime) {
_cleanup_free_ const char *path = NULL;
- usec_t x, crtime;
+ usec_t x, crtime = 0;
/* The timestamp was determined by the file name, but let's
* see if the file might actually be older than the file name
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 7fbd518..b4f88bc 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1487,7 +1487,7 @@ static int verify(sd_journal *j) {
ORDERED_HASHMAP_FOREACH(f, j->files, i) {
int k;
- usec_t first, validated, last;
+ usec_t first = 0, validated = 0, last = 0;
#ifdef HAVE_GCRYPT
if (!arg_verify_key && JOURNAL_HEADER_SEALED(f->header))
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index 3996e77..b8caeb3 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -42,7 +42,7 @@ static void verify_contents(sd_journal *j, unsigned skip) {
const void *d;
char *k, *c;
size_t l;
- unsigned u;
+ unsigned u = 0;
assert_se(sd_journal_get_cursor(j, &k) >= 0);
printf("cursor: %s\n", k);
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c
index e43d70d..e32783f 100644
--- a/src/libsystemd-network/lldp-tlv.c
+++ b/src/libsystemd-network/lldp-tlv.c
@@ -156,7 +156,7 @@ static inline int tlv_packet_read_internal(tlv_section *m, void **data) {
}
int tlv_packet_read_u8(tlv_packet *m, uint8_t *data) {
- void *val;
+ void *val = NULL;
int r;
assert_return(m, -EINVAL);
@@ -174,7 +174,7 @@ int tlv_packet_read_u8(tlv_packet *m, uint8_t *data) {
int tlv_packet_read_u16(tlv_packet *m, uint16_t *data) {
uint16_t t;
- void *val;
+ void *val = NULL;
int r;
assert_return(m, -EINVAL);
@@ -211,7 +211,7 @@ int tlv_packet_read_u32(tlv_packet *m, uint32_t *data) {
}
int tlv_packet_read_string(tlv_packet *m, char **data, uint16_t *data_length) {
- void *val;
+ void *val = NULL;
int r;
assert_return(m, -EINVAL);
@@ -229,7 +229,7 @@ int tlv_packet_read_string(tlv_packet *m, char **data, uint16_t *data_length) {
}
int tlv_packet_read_bytes(tlv_packet *m, uint8_t **data, uint16_t *data_length) {
- void *val;
+ void *val = NULL;
int r;
assert_return(m, -EINVAL);
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 2634a73..a0a2320 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -775,7 +775,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
if (pool_offset >= 0 &&
server->bound_leases[pool_offset] == existing_lease) {
DHCPLease *lease;
- usec_t time_now;
+ usec_t time_now = 0;
if (!existing_lease) {
lease = new0(DHCPLease, 1);
diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c
index e8e7d99..601f3bd 100644
--- a/src/libsystemd-network/sd-pppoe.c
+++ b/src/libsystemd-network/sd-pppoe.c
@@ -339,7 +339,7 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata);
static int pppoe_arm_timeout(sd_pppoe *ppp) {
_cleanup_event_source_unref_ sd_event_source *timeout = NULL;
- usec_t next_timeout;
+ usec_t next_timeout = 0;
int r;
assert(ppp);
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index f71749f..cc0677b 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -82,7 +82,7 @@ _public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
}
_public_ int sd_peer_get_session(int fd, char **session) {
- struct ucred ucred;
+ struct ucred ucred = {};
int r;
assert_return(fd >= 0, -EINVAL);
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 3a6faa2..4665318 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -975,7 +975,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
return r;
} else if (streq(a, "_TTL")) {
- long long unsigned x;
+ long long unsigned x = 0;
usec_t time;
r = safe_atollu(b, &x);
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 74b0634..bc1a90d 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -252,7 +252,7 @@ static int dns_transaction_open_tcp(DnsTransaction *t) {
fd = dns_scope_tcp_socket(t->scope, t->received->family, &t->received->sender, t->received->sender_port);
else {
union in_addr_union address;
- int family;
+ int family = AF_UNSPEC;
/* Otherwise, try to talk to the owner of a
* the IP address, in case this is a reverse
diff --git a/src/resolve/test-dns-domain.c b/src/resolve/test-dns-domain.c
index 2f3edaf..c3208ab 100644
--- a/src/resolve/test-dns-domain.c
+++ b/src/resolve/test-dns-domain.c
@@ -161,7 +161,7 @@ static void test_dns_name_single_label(void) {
static void test_dns_name_reverse_one(const char *address, const char *name) {
_cleanup_free_ char *p = NULL;
- union in_addr_union a, b;
+ union in_addr_union a, b = {};
int familya, familyb;
assert_se(in_addr_from_string_auto(address, &familya, &a) >= 0);
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index 6bd317f..11e0947 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -50,7 +50,7 @@ static const BaseFilesystem table[] = {
int base_filesystem_create(const char *root) {
_cleanup_close_ int fd = -1;
unsigned i;
- int r;
+ int r = 0;
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
if (fd < 0)
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 62b1eff..a95cb83 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -717,7 +717,7 @@ int btrfs_resize_loopback_fd(int fd, uint64_t new_size, bool grow_only) {
_cleanup_free_ char *p = NULL, *loop = NULL, *backing = NULL;
_cleanup_close_ int loop_fd = -1, backing_fd = -1;
struct stat st;
- dev_t dev;
+ dev_t dev = 0;
int r;
/* btrfs cannot handle file systems < 16M, hence use this as minimum */
diff --git a/src/shared/capability.c b/src/shared/capability.c
index 4840c3e..58f00e6 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -50,7 +50,7 @@ unsigned long cap_last_cap(void) {
static thread_local unsigned long saved;
static thread_local bool valid = false;
_cleanup_free_ char *content = NULL;
- unsigned long p;
+ unsigned long p = 0;
int r;
if (valid)
diff --git a/src/shared/copy.c b/src/shared/copy.c
index 9e4c3b0..775a339 100644
--- a/src/shared/copy.c
+++ b/src/shared/copy.c
@@ -360,7 +360,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
}
int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags) {
- int fdt, r;
+ int fdt = -1, r;
assert(from);
assert(to);
@@ -390,7 +390,7 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned
}
int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
int r;
assert(from);
@@ -421,7 +421,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
int copy_times(int fdf, int fdt) {
struct timespec ut[2];
struct stat st;
- usec_t crtime;
+ usec_t crtime = 0;
assert(fdf >= 0);
assert(fdt >= 0);
diff --git a/src/shared/install.c b/src/shared/install.c
index 9c680a7..1cc999b 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1793,7 +1793,7 @@ UnitFileState unit_file_lookup_state(
UnitFileState state = _UNIT_FILE_STATE_INVALID;
char **i;
_cleanup_free_ char *path = NULL;
- int r;
+ int r = 0;
assert(paths);
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 5a3ab3d..4e1b878 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -990,7 +990,7 @@ static int show_journal(FILE *f,
if (warn_cutoff && line < how_many && not_before > 0) {
sd_id128_t boot_id;
- usec_t cutoff;
+ usec_t cutoff = 0;
/* Check whether the cutoff line is too early */
diff --git a/src/shared/util.c b/src/shared/util.c
index 8b76531..605fffc 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2882,7 +2882,7 @@ int getttyname_malloc(int fd, char **ret) {
int getttyname_harder(int fd, char **r) {
int k;
- char *s;
+ char *s = NULL;
k = getttyname_malloc(fd, &s);
if (k < 0)
@@ -3435,7 +3435,7 @@ char **replace_env_argv(char **argv, char **env) {
/* If $FOO appears as single word, replace it by the split up variable */
if ((*i)[0] == '$' && (*i)[1] != '{') {
char *e;
- char **w, **m;
+ char **w, **m = NULL;
unsigned q;
e = strv_env_get(env, *i+1);
diff --git a/src/test/test-path.c b/src/test/test-path.c
index 4f9f5c1..a3295aa 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -33,7 +33,7 @@ static int setup_test(Manager **m) {
char **tests_path = STRV_MAKE("exists", "existsglobFOOBAR", "changed", "modified", "unit",
"directorynotempty", "makedirectory");
char **test_path;
- Manager *tmp;
+ Manager *tmp = NULL;
int r;
assert_se(m);
diff --git a/src/test/test-pty.c b/src/test/test-pty.c
index eadecb9..b5f4d4f 100644
--- a/src/test/test-pty.c
+++ b/src/test/test-pty.c
@@ -95,7 +95,7 @@ static void run_parent(Pty *pty) {
static void test_pty(void) {
pid_t pid;
- Pty *pty;
+ Pty *pty = NULL;
rcvsiz = 0;
zero(rcvbuf);
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 361de0d..86d09bb 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -469,7 +469,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret) {
const char *name;
- char *driver;
+ char *driver = NULL;
int r;
name = udev_device_get_sysname(device);
More information about the systemd-commits
mailing list