Skip to content

Commit 8efcebf

Browse files
committed
tests/subattr: Check return value of kdump_attr_ref_get()
The return value should never be assumed to be always KDUMP_OK. Signed-off-by: Petr Tesarik <[email protected]>
1 parent 4ab7b70 commit 8efcebf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/subattr.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ main(int argc, char **argv)
7373
status = kdump_sub_attr_ref(ctx, &ref, "uts", &subref);
7474
if (status == KDUMP_OK) {
7575
status = kdump_attr_ref_get(ctx, &subref, &attr);
76-
if (attr.type != KDUMP_DIRECTORY) {
76+
if (status != KDUMP_OK) {
77+
fprintf(stderr, "kdump_attr_ref_get failed for %s: %s\n",
78+
"uts", kdump_get_err(ctx));
79+
rc = TEST_FAIL;
80+
} else if (attr.type != KDUMP_DIRECTORY) {
7781
fprintf(stderr, "Wrong type for %s: %d\n",
7882
ATTRDIR, (int) attr.type);
7983
rc = TEST_FAIL;
@@ -89,7 +93,11 @@ main(int argc, char **argv)
8993
status = kdump_sub_attr_ref(ctx, &ref, "uts.sysname", &subref);
9094
if (status == KDUMP_OK) {
9195
status = kdump_attr_ref_get(ctx, &subref, &attr);
92-
if (attr.type != KDUMP_STRING) {
96+
if (status != KDUMP_OK) {
97+
fprintf(stderr, "kdump_attr_ref_get failed for %s: %s\n",
98+
"uts.sysname", kdump_get_err(ctx));
99+
rc = TEST_FAIL;
100+
} if (attr.type != KDUMP_STRING) {
93101
fprintf(stderr, "Wrong type for %s: %d\n",
94102
ATTRPATH, (int) attr.type);
95103
rc = TEST_FAIL;

0 commit comments

Comments
 (0)