[systemd-commits] 4 commits - src/bootchart src/journal src/libsystemd-bus src/libsystemd-daemon src/nss-myhostname src/tty-ask-password-agent
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Wed Apr 10 16:04:07 PDT 2013
src/bootchart/bootchart.c | 6 ++---
src/bootchart/svg.c | 10 +++------
src/journal/journalctl.c | 2 -
src/libsystemd-bus/bus-socket.c | 2 -
src/libsystemd-daemon/sd-daemon.c | 21 +++++---------------
src/nss-myhostname/nss-myhostname.c | 19 ++++++------------
src/tty-ask-password-agent/tty-ask-password-agent.c | 2 -
7 files changed, 23 insertions(+), 39 deletions(-)
New commits:
commit 4d3a5b10889894ec2ece20418e36cc6fd3af7c59
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Wed Apr 10 12:54:02 2013 +0200
libsystemd-bus: initalize handle_cmsg to false
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index 145f454..1a0d926 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -877,7 +877,7 @@ int bus_socket_read_message(sd_bus *bus, sd_bus_message **m) {
CMSG_SPACE(NAME_MAX)]; /*selinux label */
} control;
struct cmsghdr *cmsg;
- bool handle_cmsg;
+ bool handle_cmsg = false;
assert(bus);
assert(m);
commit cb90460e04743dd66dea37534af601786c428206
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Wed Apr 10 12:54:00 2013 +0200
tty-ask-password-agent: free passwords
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 3f5706e..1f55e32 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -339,7 +339,7 @@ static int parse_password(const char *filename, char **wall) {
}
if (arg_plymouth) {
- char **passwords = NULL;
+ _cleanup_strv_free_ char **passwords = NULL;
if ((r = ask_password_plymouth(message, not_after, filename, accept_cached, &passwords)) >= 0) {
char **p;
commit 3a819b1b6289311ebf09e94c6240dfb6be7a0496
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Wed Apr 10 12:53:58 2013 +0200
journalctl: check return of strjoin
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 86895b8..002ff7c 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1035,7 +1035,7 @@ int main(int argc, char *argv[]) {
char _cleanup_free_ *copy = NULL;
if (arg_root) {
copy = strjoin(arg_root, "/", CATALOG_DATABASE, NULL);
- if (!database) {
+ if (!copy) {
r = log_oom();
goto finish;
}
commit 1c6330456c5ae76085c63d2a7cf3d722596e545a
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Apr 5 22:24:10 2013 -0400
Use initalization instead of explicit zeroing in more places
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 208c452..288148f 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -239,7 +239,9 @@ static int parse_args(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
_cleanup_free_ char *build = NULL;
- struct sigaction sig;
+ struct sigaction sig = {
+ .sa_handler = signal_handler,
+ };
struct ps_struct *ps;
char output_file[PATH_MAX];
char datestr[200];
@@ -279,8 +281,6 @@ int main(int argc, char *argv[]) {
}
/* handle TERM/INT nicely */
- memset(&sig, 0, sizeof(struct sigaction));
- sig.sa_handler = signal_handler;
sigaction(SIGHUP, &sig, NULL);
interval = (1.0 / arg_hz) * 1000000000.0;
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index a4086c5..3472bc0 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -978,12 +978,11 @@ static void svg_ps_bars(void) {
static void svg_top_ten_cpu(void) {
struct ps_struct *top[10];
- struct ps_struct emptyps;
+ struct ps_struct emptyps = {};
struct ps_struct *ps;
int n, m;
- memset(&emptyps, 0, sizeof(struct ps_struct));
- for (n=0; n < 10; n++)
+ for (n = 0; n < (int) ELEMENTSOF(top); n++)
top[n] = &emptyps;
/* walk all ps's and setup ptrs */
@@ -1011,12 +1010,11 @@ static void svg_top_ten_cpu(void) {
static void svg_top_ten_pss(void) {
struct ps_struct *top[10];
- struct ps_struct emptyps;
+ struct ps_struct emptyps = {};
struct ps_struct *ps;
int n, m;
- memset(&emptyps, 0, sizeof(struct ps_struct));
- for (n=0; n < 10; n++)
+ for (n = 0; n < (int) ELEMENTSOF(top); n++)
top[n] = &emptyps;
/* walk all ps's and setup ptrs */
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 9cc1c37..41f4b58 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -278,11 +278,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) {
return r;
if (family > 0) {
- union sockaddr_union sockaddr;
- socklen_t l;
-
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;
@@ -297,8 +294,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) {
}
_sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
- union sockaddr_union sockaddr;
- socklen_t l;
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
int r;
if (family != 0 && family != AF_INET && family != AF_INET6)
@@ -308,9 +305,6 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u
if (r <= 0)
return r;
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
-
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;
@@ -343,17 +337,14 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u
}
_sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
- union sockaddr_union sockaddr;
- socklen_t l;
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
int r;
r = sd_is_socket_internal(fd, type, listening);
if (r <= 0)
return r;
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
-
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
index b0fb832..2dd3d4a 100644
--- a/src/nss-myhostname/nss-myhostname.c
+++ b/src/nss-myhostname/nss-myhostname.c
@@ -32,6 +32,8 @@
#include <arpa/inet.h>
#include "ifconf.h"
+#include "macro.h"
+#include "util.h"
/* We use 127.0.0.2 as IPv4 address. This has the advantage over
* 127.0.0.1 that it can be translated back to the local hostname. For
@@ -42,8 +44,6 @@
#define LOCALADDRESS_IPV6 &in6addr_loopback
#define LOOPBACK_INTERFACE "lo"
-#define ALIGN(a) (((a+sizeof(void*)-1)/sizeof(void*))*sizeof(void*))
-
enum nss_status _nss_myhostname_gethostbyname4_r(
const char *name,
struct gaih_addrtuple **pat,
@@ -96,14 +96,13 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
int32_t *ttlp) {
unsigned lo_ifi;
- char hn[HOST_NAME_MAX+1];
+ char hn[HOST_NAME_MAX+1] = {};
size_t l, idx, ms;
char *r_name;
struct gaih_addrtuple *r_tuple, *r_tuple_prev = NULL;
struct address *addresses = NULL, *a;
unsigned n_addresses = 0, n;
- memset(hn, 0, sizeof(hn));
if (gethostname(hn, sizeof(hn)-1) < 0) {
*errnop = errno;
*h_errnop = NO_RECOVERY;
@@ -312,7 +311,7 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
int32_t *ttlp,
char **canonp) {
- char hn[HOST_NAME_MAX+1];
+ char hn[HOST_NAME_MAX+1] = {};
if (af == AF_UNSPEC)
af = AF_INET;
@@ -323,7 +322,6 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
return NSS_STATUS_UNAVAIL;
}
- memset(hn, 0, sizeof(hn));
if (gethostname(hn, sizeof(hn)-1) < 0) {
*errnop = errno;
*h_errnop = NO_RECOVERY;
@@ -380,8 +378,9 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
int *errnop, int *h_errnop,
int32_t *ttlp) {
- char hn[HOST_NAME_MAX+1];
- struct address *addresses = NULL, *a;
+ char hn[HOST_NAME_MAX+1] = {};
+ struct address _cleanup_free_ *addresses = NULL;
+ struct address *a;
unsigned n_addresses = 0, n;
if (len != PROTO_ADDRESS_SIZE(af)) {
@@ -419,13 +418,9 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
*errnop = ENOENT;
*h_errnop = HOST_NOT_FOUND;
- free(addresses);
return NSS_STATUS_NOTFOUND;
found:
- free(addresses);
-
- memset(hn, 0, sizeof(hn));
if (gethostname(hn, sizeof(hn)-1) < 0) {
*errnop = errno;
*h_errnop = NO_RECOVERY;
More information about the systemd-commits
mailing list