mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
shared/utmp-wtmp: silence gcc warning about strncpy truncation
Unfortunately the warning must be known, or otherwise the pragma generates a warning or an error. So let's do a meson check for it. Is it worth doing this to silence the warning? I think so, because apparently the warning was already emitted by gcc-8.1, and with the recent push in gcc to catch more such cases, we'll most likely only get more of those.
This commit is contained in:
@@ -212,6 +212,12 @@ static inline size_t strlen_ptr(const char *s) {
|
||||
return strlen(s);
|
||||
}
|
||||
|
||||
DISABLE_WARNING_STRINGOP_TRUNCATION;
|
||||
static inline void strncpy_exact(char *buf, const char *src, size_t buf_len) {
|
||||
strncpy(buf, src, buf_len);
|
||||
}
|
||||
REENABLE_WARNING;
|
||||
|
||||
/* Like startswith(), but operates on arbitrary memory blocks */
|
||||
static inline void *memory_startswith(const void *p, size_t sz, const char *token) {
|
||||
size_t n;
|
||||
|
||||
Reference in New Issue
Block a user