poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h


From: Egeyar Bagcioglu
Subject: Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h
Date: Sun, 12 Jul 2020 20:08:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0



On 7/12/20 11:32 AM, Jose E. Marchesi wrote:
Hi Ege.

     +#define IOS_FILE_HANDLER_NORMALIZE(handler, newhandler)                   
\
     +{                                                                 \
     +  /* File devices are special, in the sense that they accept any  \
     +     handler. However, we want to ensure that the ios name is             
\
     +     unambiguous from other ios devices, by prepending ./ to relative     
\
     +     names that might otherwise be confusing.  */                 \
     +  static const char safe[] =                                              
\
     +    "abcdefghijklmnopqrstuvwxyz"                                        \
     +    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                                        \
     +    "0123456789/+_-";                                                   \
     +                                                                  \
     +  if (handler[0] == '/' || strspn (handler, safe) == strlen (handler))    
\
     +    (newhandler) = strdup ((handler));                                    
\
     +                                                                  \
     +  if (asprintf (&(newhandler), "./%s", (handler)) == -1)            \
     +    (newhandler) = NULL;                                          \
     +}

Maybe it would be better to use a static inline function here?
Otherwise, please surround the macro body with do..while(0)

Since this is a .h, included by multiple files, defining a function here is giving me a multiple definitions error. Are you happy with keeping it as a macro (with a do-while), or shall we consider something else?

Thanks
Ege

Other than that, OK for master.
Thanks! :)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]