IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 1, 2023, 4:13:02 PM (3 years ago)
Author:
eugene
Message:

add ps_strncpy_nowarn to handle overly-strict gcc version 9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/psLib/src/sys/psString.c

    r41171 r42346  
    4141
    4242
     43// gcc (Ubuntu 20.04) complains when strncpy is used to copy a fraction of a buffer,
     44// potentially skipping the ending NULL.  To avoid the error, manually copy
     45// and (to ensure the buffer ends in a NULL) set the last + 1 byte to NUL:
     46// WARNING : len(dest) must be >= n + 1
     47char *ps_strncpy_nowarn (char *dest, const char *src, size_t n) {
     48
     49  size_t i;
     50 
     51  char *d = dest;
     52  char *s = (char *) src;
     53  for (i = 0; i < n && *s != 0; i++, d++, s++) { *d = *s; }
     54  for ( ; i <= n; i++, d++) { *d = 0; }
     55 
     56  return dest;
     57}
     58
    4359psString p_psStringAlloc(const char *file,
    4460                         unsigned int lineno,
Note: See TracChangeset for help on using the changeset viewer.