Skip to content

Commit 9646696

Browse files
committed
Cleanup: Use bool for attribute flags
Use bool instead of uint8_t for attribute flags. No (intended) functional change. Signed-off-by: Petr Tesarik <[email protected]>
1 parent 3228848 commit 9646696

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

src/kdumpfile/attr.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ discard_attr_value(struct attr_data *attr)
389389

390390
discard_value(attr_value(attr), attr->template->type,
391391
attr->flags);
392-
attr->flags.dynstr = 0;
392+
attr->flags.dynstr = false;
393393
}
394394

395395
/** Clear (unset) a single attribute.
@@ -407,7 +407,7 @@ clear_single_attr(kdump_ctx_t *ctx, struct attr_data *attr)
407407
ops->pre_clear(ctx, attr);
408408

409409
discard_attr_value(attr);
410-
attr->flags.isset = 0;
410+
attr->flags.isset = false;
411411
}
412412

413413
/** Clear (unset) any attribute and its children recursively.
@@ -429,18 +429,18 @@ clear_attr(kdump_ctx_t *ctx, struct attr_data *attr)
429429
/** Clear (unset) a volatile attribute and its children recursively.
430430
* @param ctx Dump file object.
431431
* @param attr Attribute to be cleared.
432-
* @returns Non-zero if the entry could not be cleared.
432+
* @returns @c true if the entry could not be cleared.
433433
*
434434
* This function clears only volatile attributes, i.e. those that were
435435
* set automatically and should not be preserved when re-opening a dump.
436436
* Persistent attributes (e.g. those that have been set explicitly) are
437437
* kept. The complete path to each persistent attributes is also kept.
438438
*/
439-
static unsigned
439+
static bool
440440
clear_volatile(kdump_ctx_t *ctx, struct attr_data *attr)
441441
{
442442
struct attr_data *child;
443-
unsigned persist;
443+
bool persist;
444444

445445
persist = attr->flags.persist;
446446
if (attr->template->type == KDUMP_DIRECTORY)
@@ -615,7 +615,7 @@ create_attr_path(struct attr_dict *dict, struct attr_data *dir,
615615
static bool
616616
copy_data(struct attr_data *dest, const struct attr_data *src)
617617
{
618-
dest->flags.isset = 1;
618+
dest->flags.isset = true;
619619
dest->flags.persist = src->flags.persist;
620620

621621
switch (src->template->type) {
@@ -769,7 +769,7 @@ static void
769769
instantiate_path(struct attr_data *attr)
770770
{
771771
while (!attr_isset(attr)) {
772-
attr->flags.isset = 1;
772+
attr->flags.isset = true;
773773
if (!attr->parent)
774774
break;
775775
attr = attr->parent;
@@ -822,7 +822,7 @@ attr_dict_new(struct kdump_shared *shared)
822822
dict->global_attrs[i] = attr;
823823

824824
if (i >= GKI_static_first && i <= GKI_static_last) {
825-
attr->flags.indirect = 1;
825+
attr->flags.indirect = true;
826826
attr->pval = static_attr_value(shared, i);
827827
}
828828
}
@@ -944,7 +944,7 @@ set_attr(kdump_ctx_t *ctx, struct attr_data *attr,
944944
const struct attr_ops *ops = attr->template->ops;
945945
if (ops && ops->pre_set &&
946946
(res = ops->pre_set(ctx, attr, pval)) != KDUMP_OK) {
947-
flags.indirect = 0;
947+
flags.indirect = false;
948948
discard_value(pval, attr->template->type, flags);
949949
return res;
950950
}
@@ -958,12 +958,12 @@ set_attr(kdump_ctx_t *ctx, struct attr_data *attr,
958958
if (flags.indirect)
959959
attr->pval = pval;
960960
else if (attr->flags.indirect) {
961-
flags.indirect = 1;
961+
flags.indirect = true;
962962
*attr->pval = *pval;
963963
} else
964964
attr->val = *pval;
965965
}
966-
flags.isset = 1;
966+
flags.isset = true;
967967
attr->flags = flags;
968968

969969
if (!skiphooks) {
@@ -1029,7 +1029,7 @@ set_attr_string(kdump_ctx_t *ctx, struct attr_data *attr,
10291029
"Cannot allocate string");
10301030

10311031
val.string = dynstr;
1032-
flags.dynstr = 1;
1032+
flags.dynstr = true;
10331033
return set_attr(ctx, attr, flags, &val);
10341034
}
10351035

@@ -1059,7 +1059,7 @@ set_attr_sized_string(kdump_ctx_t *ctx, struct attr_data *attr,
10591059
dynstr[dynlen-1] = '\0';
10601060

10611061
val.string = dynstr;
1062-
flags.dynstr = 1;
1062+
flags.dynstr = true;
10631063
return set_attr(ctx, attr, flags, &val);
10641064
}
10651065

src/kdumpfile/diskdump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ mem_pagemap_revalidate(kdump_ctx_t *ctx, struct attr_data *attr)
989989
status = parent_revalidate(ctx, attr);
990990
if (status == KDUMP_OK) {
991991
ddp->mem_pagemap_override.ops.revalidate = parent_revalidate;
992-
attr->flags.invalid = 0;
992+
attr->flags.invalid = false;
993993
}
994994
return status;
995995
}

src/kdumpfile/kdumpfile-priv.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,11 @@ struct attr_template {
455455
/** Attribute value flags.
456456
*/
457457
struct attr_flags {
458-
uint8_t isset : 1; /**< Zero if attribute has no value */
459-
uint8_t persist : 1; /**< Persistent (not cleared on re-open) */
460-
uint8_t dynstr : 1; /**< Dynamically allocated string */
461-
uint8_t indirect : 1; /**< Actual value is at @c *pval */
462-
uint8_t invalid : 1; /**< Value needs revalidation */
458+
bool isset : 1; /**< Zero if attribute has no value */
459+
bool persist : 1; /**< Persistent (not cleared on re-open) */
460+
bool dynstr : 1; /**< Dynamically allocated string */
461+
bool indirect : 1; /**< Actual value is at @c *pval */
462+
bool invalid : 1; /**< Value needs revalidation */
463463
};
464464

465465
/** Default attribute flags. */
@@ -468,19 +468,19 @@ struct attr_flags {
468468

469469
/** Persistent attribute flags. */
470470
#define ATTR_PERSIST \
471-
((struct attr_flags){ .persist = 1 })
471+
((struct attr_flags){ .persist = true })
472472

473473
/** Indirect attribute flags. */
474474
#define ATTR_INDIRECT \
475-
((struct attr_flags){ .indirect = 1 })
475+
((struct attr_flags){ .indirect = true })
476476

477477
/** Invalid attribute flags. */
478478
#define ATTR_INVALID \
479-
((struct attr_flags){ .invalid = 1 })
479+
((struct attr_flags){ .invalid = true })
480480

481481
/** Persistent indirect attribute flags. */
482482
#define ATTR_PERSIST_INDIRECT \
483-
((struct attr_flags){ .persist = 1, .indirect = 1 })
483+
((struct attr_flags){ .persist = true, .indirect = true })
484484

485485

486486
/** Attribute template flags.
@@ -1102,9 +1102,9 @@ gattr(const kdump_ctx_t *ctx, enum global_keyidx idx)
11021102

11031103
/** Check if an attribute is set.
11041104
* @param data Pointer to the attribute data.
1105-
* @returns Non-zero if attribute data is valid.
1105+
* @returns @c true if attribute data is valid.
11061106
*/
1107-
static inline int
1107+
static inline bool
11081108
attr_isset(const struct attr_data *data)
11091109
{
11101110
return data->flags.isset;
@@ -1133,7 +1133,7 @@ attr_embed_value(struct attr_data *attr)
11331133
{
11341134
if (attr->flags.indirect) {
11351135
attr->val = *attr->pval;
1136-
attr->flags.indirect = 0;
1136+
attr->flags.indirect = false;
11371137
}
11381138
}
11391139

src/kdumpfile/open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ num_files_pre_hook(kdump_ctx_t *ctx, struct attr_data *attr,
193193
break;
194194
}
195195
if (i == 0) {
196-
fdattr->flags.indirect = 1;
196+
fdattr->flags.indirect = true;
197197
fdattr->pval = attr_mut_value(gattr(ctx, GKI_file_fd));
198198
}
199199
}

src/kdumpfile/sadump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ mem_pagemap_revalidate(kdump_ctx_t *ctx, struct attr_data *attr)
516516
ret = parent_revalidate(ctx, attr);
517517
if (ret == KDUMP_OK) {
518518
sp->mem_pagemap_override.ops.revalidate = parent_revalidate;
519-
attr->flags.invalid = 0;
519+
attr->flags.invalid = false;
520520
}
521521
return ret;
522522
}

src/kdumpfile/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ derived_attr_update(kdump_ctx_t *ctx, struct attr_data *attr,
11581158
"Writing %hu-byte values not implemented",
11591159
def->length);
11601160
}
1161-
attr->flags.invalid = 1;
1161+
attr->flags.invalid = true;
11621162

11631163
unpin:
11641164
internal_blob_unpin(blob);

src/kdumpfile/vtop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ create_addrxlat_dir(struct attr_dict *dict, enum global_keyidx dirkey)
9999
struct attr_data *dir, *attr;
100100

101101
dir = dgattr(dict, dirkey);
102-
dir->flags.isset = 1;
102+
dir->flags.isset = true;
103103

104104
for (tmpl = options; tmpl < &options[ARRAY_SIZE(options)]; ++tmpl) {
105105
attr = new_attr(dict, dir, tmpl);

0 commit comments

Comments
 (0)