summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/xalloc.h6
-rw-r--r--lib/ttyutils.c16
-rw-r--r--libblkid/src/save.c2
-rw-r--r--libblkid/src/superblocks/drbd.c2
-rw-r--r--libblkid/src/superblocks/zfs.c2
-rw-r--r--libfdisk/src/context.c2
-rw-r--r--libmount/src/optstr.c4
-rw-r--r--misc-utils/lsblk.c8
8 files changed, 24 insertions, 18 deletions
diff --git a/include/xalloc.h b/include/xalloc.h
index 0129a85e2..48712a452 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -62,8 +62,7 @@ static inline char __attribute__((warn_unused_result)) __ul_returns_nonnull
{
char *ret;
- if (!str)
- return NULL;
+ assert(str);
ret = strdup(str);
@@ -77,8 +76,7 @@ xstrndup(const char *str, size_t size)
{
char *ret;
- if (!str)
- return NULL;
+ assert(str);
ret = strndup(str, size);
diff --git a/lib/ttyutils.c b/lib/ttyutils.c
index 166e49e11..8649f435a 100644
--- a/lib/ttyutils.c
+++ b/lib/ttyutils.c
@@ -47,16 +47,16 @@ int get_terminal_dimension(int *cols, int *lines)
l = t_win.ts_lines;
}
#endif
-
- if (cols && c <= 0)
- c = get_env_int("COLUMNS");
- if (lines && l <= 0)
- l = get_env_int("LINES");
-
- if (cols)
+ if (cols) {
+ if (c <= 0)
+ c = get_env_int("COLUMNS");
*cols = c;
- if (lines)
+ }
+ if (lines) {
+ if (l <= 0)
+ l = get_env_int("LINES");
*lines = l;
+ }
return 0;
}
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 21308a9cf..bceaa1139 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -213,7 +213,7 @@ int main(int argc, char **argv)
int ret;
blkid_init_debug(BLKID_DEBUG_ALL);
- if (argc > 2) {
+ if (argc != 2) {
fprintf(stderr, "Usage: %s [filename]\n"
"Test loading/saving a cache (filename)\n", argv[0]);
exit(1);
diff --git a/libblkid/src/superblocks/drbd.c b/libblkid/src/superblocks/drbd.c
index 4ebaf1739..c27a8b384 100644
--- a/libblkid/src/superblocks/drbd.c
+++ b/libblkid/src/superblocks/drbd.c
@@ -109,7 +109,7 @@ struct meta_data_on_disk_9 {
struct peer_dev_md_on_disk_9 peers[DRBD_PEERS_MAX];
uint64_t history_uuids[HISTORY_UUIDS];
- char padding[0] __attribute__((aligned(4096)));
+ uint8_t padding[2704];
} __attribute__((packed));
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
index 4d4b46d55..0af14fb65 100644
--- a/libblkid/src/superblocks/zfs.c
+++ b/libblkid/src/superblocks/zfs.c
@@ -58,7 +58,7 @@ struct nvuint64 {
uint32_t nvu_type;
uint32_t nvu_elem;
uint64_t nvu_value;
-};
+} __attribute__((packed));
struct nvlist {
uint32_t nvl_unknown[3];
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 3677648e9..770aa4d52 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -675,7 +675,7 @@ int fdisk_assign_device(struct fdisk_context *cxt,
fd = open(fname, (readonly ? O_RDONLY : O_RDWR ) | O_CLOEXEC);
if (fd < 0) {
- int rc = -errno;
+ rc = -errno;
DBG(CXT, ul_debugobj(cxt, "failed to assign device [rc=%d]", rc));
return rc;
}
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index c0f438fe2..49fc9cc40 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -351,7 +351,9 @@ int mnt_optstr_deduplicate_option(char **optstr, const char *name)
end = ol.end;
opt = end && *end ? end + 1 : NULL;
}
- } while (rc == 0 && opt && *opt);
+ if (opt == NULL)
+ break;
+ } while (rc == 0 && *opt);
return rc < 0 ? rc : begin ? 0 : 1;
}
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 3ce6da730..7ab9dc23c 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -774,8 +774,14 @@ static char *device_get_data(
str = get_vfs_attribute(dev, id);
break;
case COL_TARGET:
- str = xstrdup(lsblk_device_get_mountpoint(dev));
+ {
+ char *s = lsblk_device_get_mountpoint(dev);
+ if (s)
+ str = xstrdup(s);
+ else
+ str = NULL;
break;
+ }
case COL_LABEL:
prop = lsblk_device_get_properties(dev);
if (prop && prop->label)