Skip to content

Fix -Wstringop-truncation warnings in safe_strncpy()

Alan Coopersmith requested to merge alanc/sessreg:misc into master
In function ‘safe_strncpy’,
    inlined from ‘set_utmpx’ at sessreg.c:540:3,
    inlined from ‘main’ at sessreg.c:357:2:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~
In function ‘safe_strncpy’,
    inlined from ‘set_utmpx’ at sessreg.c:530:4,
    inlined from ‘main’ at sessreg.c:357:2:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~
In function ‘safe_strncpy’,
    inlined from ‘set_utmpx’ at sessreg.c:532:3,
    inlined from ‘main’ at sessreg.c:357:2:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 257 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~
In function ‘safe_strncpy’,
    inlined from ‘set_utmpx’ at sessreg.c:540:3,
    inlined from ‘main’ at sessreg.c:357:2:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~
In function ‘safe_strncpy’,
    inlined from ‘main’ at sessreg.c:423:5:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 8 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~
In function ‘safe_strncpy’,
    inlined from ‘main’ at sessreg.c:425:5:
sessreg.c:204:11: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  204 |     (void)strncpy(dest, src, n);
      |           ^~~~~~~~~~~~~~~~~~~~~

Merge request reports

Loading