This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit c0fc222b19b1e5de3a56998103cd16daac9fa2a0
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Mon Mar 25 21:44:40 2019 +0000
libgfs2: lgfs2_field_str: Separate field extraction from printing
In lgfs2_field_str, separate the extracting a field of known bit width
from printing that field by converting all fields into a temporary
64-bit value. This will simplify the next patch.
---
gfs2/libgfs2/meta.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 19d0c41..c151148 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -946,23 +946,33 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk,
const struct
} else if (field->flags & LGFS2_MFF_STRING) {
snprintf(str, size, "%s", fieldp);
} else {
+ uint64_t value;
+
switch(field->length) {
case sizeof(uint8_t):
- snprintf(str, size, hex? "%"PRIx8 : "%"PRIu8, *(uint8_t
*)fieldp);
+ value = *(uint8_t *)fieldp;
break;
case sizeof(uint16_t):
- snprintf(str, size, hex? "%"PRIx16 : "%"PRIu16,
be16_to_cpu(*(uint16_t *)fieldp));
+ value = be16_to_cpu(*(uint16_t *)fieldp);
break;
case sizeof(uint32_t):
- snprintf(str, size, hex? "%"PRIx32 : "%"PRIu32,
be32_to_cpu(*(uint32_t *)fieldp));
+ value = be32_to_cpu(*(uint32_t *)fieldp);
break;
case sizeof(uint64_t):
- snprintf(str, size, hex? "%"PRIx64 : "%"PRIu64,
be64_to_cpu(*(uint64_t *)fieldp));
+ value = be64_to_cpu(*(uint64_t *)fieldp);
break;
default:
- break;
+ *str = 0;
+ goto out;
+ }
+
+ if (hex) {
+ snprintf(str, size, "%"PRIx64, value);
+ goto out;
}
+ snprintf(str, size, "%"PRIu64, value);
}
+out:
str[size - 1] = '\0';
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date