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/initrd.c | |
| parent | 8d90fb3e4a5d02df75584016563ef84901967b9f (diff) | |
| download | kmi-acc26f85f32c68a51e5cc7b613cd0ea0b0630505.tar.gz kmi-acc26f85f32c68a51e5cc7b613cd0ea0b0630505.zip | |
Use #if defined(...) when not guard clause
Diffstat (limited to 'common/initrd.c')
| -rw-r--r-- | common/initrd.c | 20 |
1 files changed, 10 insertions, 10 deletions
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); |
