diff --git a/libs/libc/signal/sig_psignal.c b/libs/libc/signal/sig_psignal.c index 48355f688d..5ae92b136b 100644 --- a/libs/libc/signal/sig_psignal.c +++ b/libs/libc/signal/sig_psignal.c @@ -63,8 +63,8 @@ * the string pointed to by the message argument will be written, * followed by a colon and a space. * - * Then the signal description string associated with signum or with the - * signal indicated by pinfo will be written, followed by a newline. + * Then the signal description string associated with signum will be + * written, followed by a newline. * * Returned Value * None. The errno value is never set in this implementation. @@ -99,8 +99,8 @@ void psignal(int signum, FAR const char *message) * the string pointed to by the message argument will be written, * followed by a colon and a space. * - * Then the signal description string associated with signum or with the - * signal indicated by pinfo will be written, followed by a newline. + * Then the signal description string associated with the signal + * indicated by pinfo will be written, followed by a newline. * * Returned Value * None. Since no value is returned, an application wishing to check for @@ -121,4 +121,4 @@ void psiginfo(FAR const siginfo_t *pinfo, FAR const char *message) } } -#endif /* __KERNEL__ */ +#endif /* !__KERNEL__ */ diff --git a/libs/libc/string/lib_stpncpy.c b/libs/libc/string/lib_stpncpy.c index 83daaadec2..48f058d17d 100644 --- a/libs/libc/string/lib_stpncpy.c +++ b/libs/libc/string/lib_stpncpy.c @@ -78,17 +78,24 @@ FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n) * encountered. */ - while ((dest != end) && (*dest++ = *src++) != '\0') + while ((dest != end) && (*dest = *src++) != '\0') { + /* Increment the 'dest' pointer only if it does not refer to the + * NUL terminator. + */ + + dest++; } /* Return the pointer to the NUL terminator (or to the end of the buffer - * + 1. + * + 1). */ ret = dest; - /* Pad the remainder of the array pointer to 'dest' with NULs */ + /* Pad the remainder of the array pointer to 'dest' with NULs. This + * overwrites any previously copied NUL terminator. + */ while (dest != end) {