IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42346


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

Location:
branches/eam_branches/ipp-20220316/psLib/src/sys
Files:
3 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,
  • branches/eam_branches/ipp-20220316/psLib/src/sys/psString.h

    r40551 r42346  
    4848void psNOOP (void);
    4949
     50char *ps_strncpy_nowarn (char *dest, const char *src, size_t n);
     51
    5052// some constants to use in snprintf statements and variable definitions to ensure
    5153// consistency
  • branches/eam_branches/ipp-20220316/psLib/src/sys/psTrace.c

    r26892 r42346  
    213213    }
    214214
    215     strncpy(name, addNodeName, MAX_COMPONENT_LENGTH);
     215    ps_strncpy_nowarn(name, addNodeName, MAX_COMPONENT_LENGTH);
    216216    char *pname = name+1;               // Take off the period
    217217    // Iterate through the components of addNodeName.  Strip off the first
Note: See TracChangeset for help on using the changeset viewer.