git: a2aff11aeb5d - main - dev/fdt: Add const to pointers to const data
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Apr 2025 10:49:14 UTC
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a2aff11aeb5de30c2d28567aa6189926e2c10ba3 commit a2aff11aeb5de30c2d28567aa6189926e2c10ba3 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2025-04-08 10:30:56 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2025-04-08 10:48:28 +0000 dev/fdt: Add const to pointers to const data fdt_data_get and fdt_data_to_res don't change the value of the data passed to them via a pointer. Add const to these pointers. Reviewed by: emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D49703 --- sys/dev/fdt/fdt_common.c | 14 +++++++------- sys/dev/fdt/fdt_common.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 8a0e414595f2..40b1b3c5fc4f 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -303,13 +303,13 @@ fdt_parent_addr_cells(phandle_t node) } u_long -fdt_data_get(void *data, int cells) +fdt_data_get(const void *data, int cells) { if (cells == 1) - return (fdt32_to_cpu(*((uint32_t *)data))); + return (fdt32_to_cpu(*((const uint32_t *)data))); - return (fdt64_to_cpu(*((uint64_t *)data))); + return (fdt64_to_cpu(*((const uint64_t *)data))); } int @@ -336,22 +336,22 @@ fdt_addrsize_cells(phandle_t node, int *addr_cells, int *size_cells) } int -fdt_data_to_res(pcell_t *data, int addr_cells, int size_cells, u_long *start, - u_long *count) +fdt_data_to_res(const pcell_t *data, int addr_cells, int size_cells, + u_long *start, u_long *count) { /* Address portion. */ if (addr_cells > 2) return (ERANGE); - *start = fdt_data_get((void *)data, addr_cells); + *start = fdt_data_get((const void *)data, addr_cells); data += addr_cells; /* Size portion. */ if (size_cells > 2) return (ERANGE); - *count = fdt_data_get((void *)data, size_cells); + *count = fdt_data_get((const void *)data, size_cells); return (0); } diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h index dbf809625da3..e49049051209 100644 --- a/sys/dev/fdt/fdt_common.h +++ b/sys/dev/fdt/fdt_common.h @@ -79,8 +79,8 @@ SYSCTL_DECL(_hw_fdt); typedef void (*fdt_mem_region_cb)(const struct mem_region *, void *); int fdt_addrsize_cells(phandle_t, int *, int *); -u_long fdt_data_get(void *, int); -int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *); +u_long fdt_data_get(const void *, int); +int fdt_data_to_res(const pcell_t *, int, int, u_long *, u_long *); phandle_t fdt_find_compatible(phandle_t, const char *, int); phandle_t fdt_depth_search_compatible(phandle_t, const char *, int); int fdt_foreach_mem_region(fdt_mem_region_cb, void *);