chiark / gitweb /
sd-daemon: remove unnecessary memset calls
authorJim Meyering <jim@meyering.net>
Thu, 16 Jun 2011 06:51:14 +0000 (08:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jul 2012 22:06:06 +0000 (00:06 +0200)
There is no point in clearing the bits of a "struct stat" when the very
next statement just calls stat or fstat to fill in that same memory.

[zj: two more places]

src/core/load-fragment.c
src/core/service.c
src/libsystemd-daemon/sd-daemon.c

index 7fcd63a17a69b3d05124cf712a526f48225d1689..bbd82b9d2472d4cda178d530fbb49506da80cad4 100644 (file)
@@ -2287,7 +2287,6 @@ static int load_from_path(Unit *u, const char *path) {
                 goto finish;
         }
 
                 goto finish;
         }
 
-        zero(st);
         if (fstat(fileno(f), &st) < 0) {
                 r = -errno;
                 goto finish;
         if (fstat(fileno(f), &st) < 0) {
                 r = -errno;
                 goto finish;
index 30598de9b85ce380769df1953b939184dbc8c34b..1c127bdbcb2ffc5c6926d210a63d278ea90078a8 100644 (file)
@@ -564,7 +564,6 @@ static int service_load_sysv_path(Service *s, const char *path) {
                 goto finish;
         }
 
                 goto finish;
         }
 
-        zero(st);
         if (fstat(fileno(f), &st) < 0) {
                 r = -errno;
                 goto finish;
         if (fstat(fileno(f), &st) < 0) {
                 r = -errno;
                 goto finish;
index 763e079b4ec0ac7cfa9bda49341e29a0672f2e87..863ac7529060d7560e765aeb612dcebc422fb259 100644 (file)
@@ -152,7 +152,6 @@ _sd_export_ int sd_is_fifo(int fd, const char *path) {
         if (fd < 0)
                 return -EINVAL;
 
         if (fd < 0)
                 return -EINVAL;
 
-        memset(&st_fd, 0, sizeof(st_fd));
         if (fstat(fd, &st_fd) < 0)
                 return -errno;
 
         if (fstat(fd, &st_fd) < 0)
                 return -errno;
 
@@ -162,7 +161,6 @@ _sd_export_ int sd_is_fifo(int fd, const char *path) {
         if (path) {
                 struct stat st_path;
 
         if (path) {
                 struct stat st_path;
 
-                memset(&st_path, 0, sizeof(st_path));
                 if (stat(path, &st_path) < 0) {
 
                         if (errno == ENOENT || errno == ENOTDIR)
                 if (stat(path, &st_path) < 0) {
 
                         if (errno == ENOENT || errno == ENOTDIR)