This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 90d0e320b603a9104937392638e851a6a6db936e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 18:05:49 2021 +0100
gfs2l: Sparse fixes
Remove a VLA and fix the endianness tagging of some casts.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 15 +++++++++++----
gfs2/libgfs2/lang.c | 6 +++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 15dcd25d..6fc6cd37 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -28,10 +28,16 @@ static int metastrcmp(const void *a, const void *b)
return strcmp(m1->name, m2->name);
}
-static void print_structs(void)
+static int print_structs(void)
{
- const struct lgfs2_metadata *mlist[lgfs2_metadata_size];
+ const struct lgfs2_metadata **mlist;
int i;
+
+ mlist = calloc(lgfs2_metadata_size, sizeof(struct lgfs2_metadata *));
+ if (mlist == NULL) {
+ perror("Failed to create metadata type array");
+ return 1;
+ }
for (i = 0; i < lgfs2_metadata_size; i++)
mlist[i] = &lgfs2_metadata[i];
@@ -39,6 +45,8 @@ static void print_structs(void)
for (i = 0; i < lgfs2_metadata_size; i++)
if (mlist[i]->mh_type != GFS2_METATYPE_NONE)
printf("%s\n", mlist[i]->name);
+ free(mlist);
+ return 0;
}
static void print_fields(const char *name)
@@ -69,8 +77,7 @@ static int getopts(int argc, char *argv[], struct cmdopts *opts)
}
break;
case 'T':
- print_structs();
- exit(0);
+ exit(print_structs());
case 'F':
print_fields(optarg);
exit(0);
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 740d1a7b..dd46cd21 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -327,13 +327,13 @@ static int field_print(char *buf, uint64_t addr, const struct
lgfs2_metadata *mt
printf("%"PRIu8"\n", *(uint8_t *)fieldp);
break;
case 2:
- printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t *)fieldp));
+ printf("%"PRIu16"\n", be16_to_cpu(*(__be16 *)fieldp));
break;
case 4:
- printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t *)fieldp));
+ printf("%"PRIu32"\n", be32_to_cpu(*(__be32 *)fieldp));
break;
case 8:
- printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t *)fieldp));
+ printf("%"PRIu64"\n", be64_to_cpu(*(__be64 *)fieldp));
break;
default:
// "Reserved" field so just print 0
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date