lkml.org 
[lkml]   [2022]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 03/34] brcmfmac: firmware: Support having multiple alt paths
    From
    Date
    03.01.2022 03:41, Hector Martin пишет:
    >> There is indeed no need for the castings in such cases, it's a typical
    >> code pattern in kernel. You would need to do the casting for the other
    >> way around, i.e. if char ** was returned and **alt_paths was a const.
    > You do need to do the cast. Try it.
    >
    > $ cat test.c
    > int main() {
    > char *foo[1];
    > const char **bar = foo;
    >
    > return 0;
    > }
    >
    > $ gcc test.c
    > test.c: In function ‘main’:
    > test.c:4:28: warning: initialization of ‘const char **’ from
    > incompatible pointer type ‘char **’ [-Wincompatible-pointer-types]
    > 4 | const char **bar = foo;
    > |
    >
    > You can implicitly cast char* to const char*, but you *cannot*
    > impliclicitly cast char** to const char** for the reason I explained. It
    > requires a cast.

    Right, I read it as "char * const *". The "const char **" vs "char *
    const *" always confuses me.

    Hence you should've written "const char **alt_paths;" in
    brcm_alt_fw_paths() in the first place and then casting wouldn't have
    been needed.

    \
     
     \ /
      Last update: 2022-01-03 02:27    [W:4.434 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site