mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 12:13:33 +08:00
tree-wide: use 'Architecture' type consistently across the tree
Some parts of our tree used 'Architecture' for storing architectures, others used ints. Let's unify on the former. Inspired by #22952's rework of the 'Virtualization' enum.
This commit is contained in:
parent
9858e6d2e7
commit
6b41a7b281
@ -7,7 +7,7 @@
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
|
||||
int uname_architecture(void) {
|
||||
Architecture uname_architecture(void) {
|
||||
|
||||
/* Return a sanitized enum identifying the architecture we are running on. This
|
||||
* is based on uname(), and the user may hence control what this returns by using
|
||||
@ -22,7 +22,7 @@ int uname_architecture(void) {
|
||||
|
||||
static const struct {
|
||||
const char *machine;
|
||||
int arch;
|
||||
Architecture arch;
|
||||
} arch_map[] = {
|
||||
#if defined(__aarch64__) || defined(__arm__)
|
||||
{ "aarch64", ARCHITECTURE_ARM64 },
|
||||
@ -122,7 +122,7 @@ int uname_architecture(void) {
|
||||
#endif
|
||||
};
|
||||
|
||||
static int cached = _ARCHITECTURE_INVALID;
|
||||
static Architecture cached = _ARCHITECTURE_INVALID;
|
||||
struct utsname u;
|
||||
|
||||
if (cached != _ARCHITECTURE_INVALID)
|
||||
@ -175,4 +175,4 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = {
|
||||
[ARCHITECTURE_TILEGX] = "tilegx",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(architecture, int);
|
||||
DEFINE_STRING_TABLE_LOOKUP(architecture, Architecture);
|
||||
|
@ -48,7 +48,7 @@ typedef enum {
|
||||
_ARCHITECTURE_INVALID = -EINVAL,
|
||||
} Architecture;
|
||||
|
||||
int uname_architecture(void);
|
||||
Architecture uname_architecture(void);
|
||||
|
||||
/*
|
||||
* LIB_ARCH_TUPLE should resolve to the local library path
|
||||
@ -243,5 +243,5 @@ int uname_architecture(void);
|
||||
# error "Please register your architecture here!"
|
||||
#endif
|
||||
|
||||
const char *architecture_to_string(int a) _const_;
|
||||
int architecture_from_string(const char *s) _pure_;
|
||||
const char *architecture_to_string(Architecture a) _const_;
|
||||
Architecture architecture_from_string(const char *s) _pure_;
|
||||
|
@ -1026,7 +1026,7 @@ bool oom_score_adjust_is_valid(int oa) {
|
||||
}
|
||||
|
||||
unsigned long personality_from_string(const char *p) {
|
||||
int architecture;
|
||||
Architecture architecture;
|
||||
|
||||
if (!p)
|
||||
return PERSONALITY_INVALID;
|
||||
@ -1050,7 +1050,7 @@ unsigned long personality_from_string(const char *p) {
|
||||
}
|
||||
|
||||
const char* personality_to_string(unsigned long p) {
|
||||
int architecture = _ARCHITECTURE_INVALID;
|
||||
Architecture architecture = _ARCHITECTURE_INVALID;
|
||||
|
||||
if (p == PER_LINUX)
|
||||
architecture = native_architecture();
|
||||
|
@ -490,7 +490,7 @@ static int condition_test_virtualization(Condition *c, char **env) {
|
||||
}
|
||||
|
||||
static int condition_test_architecture(Condition *c, char **env) {
|
||||
int a, b;
|
||||
Architecture a, b;
|
||||
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
|
@ -612,7 +612,7 @@ static void dissected_partition_done(DissectedPartition *p) {
|
||||
|
||||
*p = (DissectedPartition) {
|
||||
.partno = -1,
|
||||
.architecture = -1
|
||||
.architecture = _ARCHITECTURE_INVALID,
|
||||
};
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ int dissect_image(
|
||||
|
||||
if (is_gpt) {
|
||||
PartitionDesignator designator = _PARTITION_DESIGNATOR_INVALID;
|
||||
int architecture = _ARCHITECTURE_INVALID;
|
||||
Architecture architecture = _ARCHITECTURE_INVALID;
|
||||
const char *stype, *sid, *fstype = NULL, *label;
|
||||
sd_id128_t type_id, id;
|
||||
bool rw = true, growfs = false;
|
||||
|
@ -20,9 +20,9 @@ struct DissectedPartition {
|
||||
bool found:1;
|
||||
bool rw:1;
|
||||
bool growfs:1;
|
||||
int partno; /* -1 if there was no partition and the images contains a file system directly */
|
||||
int architecture; /* Intended architecture: either native, secondary or unset (-1). */
|
||||
sd_id128_t uuid; /* Partition entry UUID as reported by the GPT */
|
||||
int partno; /* -1 if there was no partition and the images contains a file system directly */
|
||||
Architecture architecture; /* Intended architecture: either native, secondary or unset ARCHITECTURE_INVALID. */
|
||||
sd_id128_t uuid; /* Partition entry UUID as reported by the GPT */
|
||||
char *fstype;
|
||||
char *node;
|
||||
char *label;
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Virtualization v;
|
||||
Architecture a;
|
||||
const char *p;
|
||||
int a;
|
||||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
|
@ -276,7 +276,7 @@ TEST(condition_test_host) {
|
||||
TEST(condition_test_architecture) {
|
||||
Condition *condition;
|
||||
const char *sa;
|
||||
int a;
|
||||
Architecture a;
|
||||
|
||||
a = uname_architecture();
|
||||
assert_se(a >= 0);
|
||||
|
@ -17,7 +17,7 @@ TEST(gpt_types_against_architectures) {
|
||||
* types. Also validates whether we can properly categorize the entries. */
|
||||
|
||||
FOREACH_STRING(prefix, "root-", "usr-")
|
||||
for (int a = 0; a < _ARCHITECTURE_MAX; a++)
|
||||
for (Architecture a = 0; a < _ARCHITECTURE_MAX; a++)
|
||||
FOREACH_STRING(suffix, "", "-verity", "-verity-sig") {
|
||||
_cleanup_free_ char *joined = NULL;
|
||||
sd_id128_t id;
|
||||
|
Loading…
Reference in New Issue
Block a user