04.01.2022 11:43, Hector Martin пишет: >>> +static int brcm_alt_fw_paths(const char *path, const char *board_type, >>> + const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS])> { >>> char alt_path[BRCMF_FW_NAME_LEN]; >>> const char *suffix; >>> >>> + memset(alt_paths, 0, array_size(sizeof(*alt_paths), >>> + BRCMF_FW_MAX_ALT_PATHS)); >> You don't need to use array_size() since size of a fixed array is >> already known. >> >> memset(alt_paths, 0, sizeof(alt_paths)); > It's a function argument, so that doesn't work and actually throws a > warning. Array function argument notation is informative only; they > behave strictly equivalent to pointers. Try it: > > $ cat test.c > #include <stdio.h> > > void foo(char x[42]) > { > printf("%ld\n", sizeof(x)); > } > > int main() { > char x[42]; > > foo(x); > } > $ gcc test.c > test.c: In function ‘foo’: > test.c:5:31: warning: ‘sizeof’ on array function parameter ‘x’ will > return size of ‘char *’ [-Wsizeof-array-argument] > 5 | printf("%ld\n", sizeof(x)); > | ^ > test.c:3:15: note: declared here > 3 | void foo(char x[42]) > | ~~~~~^~~~~ > $ ./a.out > 8 Then please use "const char **alt_paths" for the function argument to make code cleaner and add another argument to pass the number of array elements. static int brcm_alt_fw_paths(const char *path, const char *board_type, const char **alt_paths, unsigned int num_paths) { size_t alt_paths_size = array_size(sizeof(*alt_paths), num_paths); memset(alt_paths, 0, alt_paths_size); } ... Maybe even better create a dedicated struct for the alt_paths: struct brcmf_fw_alt_paths { const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS]; unsigned int index; }; and then use the ".index" in the brcm_free_alt_fw_paths(). I suppose this will make code a bit nicer and easier to follow.