From fe7ef272d0e09015b1ef9107b578b32b7ee9d706 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 25 Mar 2021 10:43:20 +0100 Subject: [PATCH] libfdisk: make labels allocations readable for analysers [coverity scan] Signed-off-by: Karel Zak --- libfdisk/src/bsd.c | 3 ++- libfdisk/src/dos.c | 3 ++- libfdisk/src/gpt.c | 3 ++- libfdisk/src/sgi.c | 3 ++- libfdisk/src/sun.c | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c index a7e2791a7c..313ae5ae0f 100644 --- a/libfdisk/src/bsd.c +++ b/libfdisk/src/bsd.c @@ -1060,5 +1060,6 @@ struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt __attribute__ lb->flags |= FDISK_LABEL_FL_INCHARS_PARTNO; lb->flags |= FDISK_LABEL_FL_REQUIRE_GEOMETRY; - return lb; + /* return calloc() result to keep static anaylizers happy */ + return (struct fdisk_label *) bsd; } diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 463886e172..543856f182 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -2680,7 +2680,8 @@ struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt __attribute__ lb->geom_max.heads = 255; lb->geom_max.cylinders = 1048576; - return lb; + /* return calloc() result to keep static anaylizers happy */ + return (struct fdisk_label *) dos; } /** diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 6a01b1d618..6b07d9841e 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -3213,7 +3213,8 @@ struct fdisk_label *fdisk_new_gpt_label(struct fdisk_context *cxt __attribute__ lb->fields = gpt_fields; lb->nfields = ARRAY_SIZE(gpt_fields); - return lb; + /* return calloc() result to keep static anaylizers happy */ + return (struct fdisk_label *) gpt; } /** diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index 6b4b5d116f..64adf34543 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -1204,5 +1204,6 @@ struct fdisk_label *fdisk_new_sgi_label(struct fdisk_context *cxt __attribute__ lb->flags |= FDISK_LABEL_FL_REQUIRE_GEOMETRY; - return lb; + /* return calloc() result to keep static anaylizers happy */ + return (struct fdisk_label *) sgi; } diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 833f421a83..4c3b1d8cb6 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -1186,5 +1186,7 @@ struct fdisk_label *fdisk_new_sun_label(struct fdisk_context *cxt __attribute__ lb->geom_max.sectors = 1024; lb->geom_max.heads = 1024; lb->geom_max.cylinders = USHRT_MAX; - return lb; + + /* return calloc() result to keep static anaylizers happy */ + return (struct fdisk_label *) sun; } -- 2.47.2