PengZheng commented on issue #471:
URL: https://github.com/apache/celix/issues/471#issuecomment-1396916768

   For MacOS, I found `va_list` something like this:
   
   ```C
   typedef struct {
     char gpr;                  /* index into the array of 8 GPRs stored in the
                                   register save area gpr=0 corresponds to r3,
                                   gpr=1 to r4, etc. */
     char fpr;                  /* index into the array of 8 FPRs stored in the
                                   register save area fpr=0 corresponds to f1,
                                   fpr=1 to f2, etc. */
     char *overflow_arg_area;   /* location on stack that holds the next
                                   overflow argument */
     char *reg_save_area;               /* where r3:r10 and f1:f8, if saved are 
stored */
   } __va_list[1];
   
   #elif        defined(_HIDDEN_VA_LIST) && defined(_VA_LIST)
   
   #undef _HIDDEN_VA_LIST
   typedef __va_list va_list;
   ``` 
   
   
https://opensource.apple.com/source/xnu/xnu-201/osfmk/libsa/ppc/va_list.h.auto.html
   
   Then the following seems buggy:
   
   ```C
       char buffer[1024];
       size_t needed = vsnprintf(buffer, 1024, format, formatArgs); 
//formatArgs is modified HERE
       if (needed > 1024) {
           char *allocatedBuffer = NULL;
           vasprintf(&allocatedBuffer, format, formatArgs); //formatArgs is 
used again
           syslog(sysLogLvl, "[%s]: %s", logServiceName, allocatedBuffer);
           free(allocatedBuffer);
       } else {
           syslog(sysLogLvl, "[%s]: %s", logServiceName, buffer);
       }
   ```
   
   We may need a `va_copy` here. I'll give it a try.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to