diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-01-07 20:50:16 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-01-07 20:50:16 +0200 |
| commit | acc26f85f32c68a51e5cc7b613cd0ea0b0630505 (patch) | |
| tree | 90d68a8292360f0796509f1febc7b66b0a53f4aa /common | |
| parent | 8d90fb3e4a5d02df75584016563ef84901967b9f (diff) | |
| download | kmi-acc26f85f32c68a51e5cc7b613cd0ea0b0630505.tar.gz kmi-acc26f85f32c68a51e5cc7b613cd0ea0b0630505.zip | |
Use #if defined(...) when not guard clause
Diffstat (limited to 'common')
| -rw-r--r-- | common/bits.c | 6 | ||||
| -rw-r--r-- | common/debug.c | 6 | ||||
| -rw-r--r-- | common/fdt.c | 4 | ||||
| -rw-r--r-- | common/initrd.c | 20 |
4 files changed, 18 insertions, 18 deletions
diff --git a/common/bits.c b/common/bits.c index ca99ed2..b9814f6 100644 --- a/common/bits.c +++ b/common/bits.c @@ -4,13 +4,13 @@ #include <apos/builtin.h> #undef __bswap16 -__weak uint16_t __bswap16(uint16_t u) +__weak uint16_t __bswap16(const uint16_t u) { return (u & 0xff00) >> 8 | (u & 0x00ff) << 8; } #undef __bswap32 -__weak uint32_t __bswap32(uint32_t u) +__weak uint32_t __bswap32(const uint32_t u) { return (u & 0xff000000) >> 24 | (u & 0x00ff0000) >> 8 | @@ -19,7 +19,7 @@ __weak uint32_t __bswap32(uint32_t u) } #undef __bswap64 -__weak uint64_t __bswap64(uint64_t u) +__weak uint64_t __bswap64(const uint64_t u) { return (u & 0xff00000000000000ULL) >> 56 | (u & 0x00ff000000000000ULL) >> 40 | diff --git a/common/debug.c b/common/debug.c index aab5abc..330a3ed 100644 --- a/common/debug.c +++ b/common/debug.c @@ -7,13 +7,13 @@ #include <libfdt.h> #include <stdarg.h> -#ifdef DEBUG +#if defined(DEBUG) static struct dbg_info { pm_t dbg_ptr; enum serial_dev dev; } dbg_info = (struct dbg_info){0}; -void init_dbg(void *fdt) +void init_dbg(const void *fdt) { dbg_info = dbg_from_fdt(fdt); } @@ -88,7 +88,7 @@ static enum serial_dev __serial_dev_enum(const char *dev_name) return -1; } -struct dbg_info dbg_from_fdt(void *fdt) +struct dbg_info dbg_from_fdt(const void *fdt) { int chosen_offset = fdt_path_offset(fdt, "/chosen"); const char *stdout = fdt_getprop(fdt, chosen_offset, "stdout-path", NULL); diff --git a/common/fdt.c b/common/fdt.c index f76ad64..7cec3a4 100644 --- a/common/fdt.c +++ b/common/fdt.c @@ -1,6 +1,6 @@ #include <libfdt.h> -struct cell_info get_cellinfo(void *fdt, int offset) +struct cell_info get_cellinfo(const void *fdt, const int offset) { return (struct cell_info){ fdt_size_cells(fdt, offset), @@ -9,7 +9,7 @@ struct cell_info get_cellinfo(void *fdt, int offset) } /* how "reg" is interpreted depends on the parent node */ -struct cell_info get_reginfo(void *fdt, const char *path) +struct cell_info get_reginfo(const void *fdt, const char *path) { const char *i = strrchr(path, '/'); if(!i) diff --git a/common/initrd.c b/common/initrd.c index 691685a..7b5fa6c 100644 --- a/common/initrd.c +++ b/common/initrd.c @@ -31,7 +31,7 @@ static struct cpio_header *__next_entry(struct cpio_header *cp) return (struct cpio_header *)(((char *)cp) + blen + tlen); } -static struct cpio_header *__find_file(char *c, char* fname, size_t fname_len) +static struct cpio_header *__find_file(const char *c, const char* fname, size_t fname_len) { struct cpio_header *cp = (struct cpio_header *)c; for(; cp; cp = __next_entry(cp)){ @@ -53,7 +53,7 @@ static struct cpio_header *__find_file(char *c, char* fname, size_t fname_len) return 0; } -pm_t get_initrdtop(void *fdt) +pm_t get_initrdtop(const void *fdt) { int chosen_offset = fdt_path_offset(fdt, "/chosen"); struct cell_info ci = get_cellinfo(fdt, chosen_offset); @@ -65,10 +65,10 @@ pm_t get_initrdtop(void *fdt) return (pm_t)__va(fdt_load_int_ptr(ci.addr_cells, initrd_end_ptr)); } -pm_t get_initrdbase(void *fdt) +pm_t get_initrdbase(const void *fdt) { - int chosen_offset = fdt_path_offset(fdt, "/chosen"); - struct cell_info ci = get_cellinfo(fdt, chosen_offset); + const int chosen_offset = fdt_path_offset(fdt, "/chosen"); + const struct cell_info ci = get_cellinfo(fdt, chosen_offset); void *initrd_base_ptr = (void *)fdt_getprop(fdt, chosen_offset, "linux,initrd-start", NULL); @@ -79,14 +79,14 @@ pm_t get_initrdbase(void *fdt) static char init_n[] = "init"; static size_t init_nlen = ARRAY_SIZE(init_n) - 1; /* ignore trailing NULL */ -size_t get_init_size(void *fdt) +size_t get_init_size(const void *fdt) { char *c = (char *)get_initrdbase(fdt); struct cpio_header *cp = __find_file(c, init_n, init_nlen); return convnum(cp->c_filesize, 8, 16); } -vm_t get_init_base(void *fdt) +vm_t get_init_base(const void *fdt) { char *c = (char *)get_initrdbase(fdt); struct cpio_header *cp = __find_file(c, init_n, init_nlen); @@ -94,11 +94,11 @@ vm_t get_init_base(void *fdt) return ((vm_t)cp) + align_up(sizeof(struct cpio_header) + name_len, 4); } -void move_init(void *fdt, void *target) +void move_init(const void *fdt, void *target) { - char *c = (char *)get_initrdbase(fdt); + const char *c = (const char *)get_initrdbase(fdt); - struct cpio_header *cp = __find_file(c, init_n, init_nlen); + const struct cpio_header *cp = __find_file(c, init_n, init_nlen); size_t name_len = convnum(cp->c_namesize, 8, 16); size_t file_len = convnum(cp->c_filesize, 8, 16); |
