mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-24 18:05:22 +00:00
HV: rewrite strncpy_s to be iso c11 compliant
Per C11 standard (ISO/IEC 9899:2011): K.3.7.1.4 1. Copying shall not take place between objects that overlap; 2. If there is a runtime-constraint violation, the strncpy_s function sets s1[0] to '\0\; 3. The strncpy_s function returns zero if there was no runtime-constraint violation. Otherwise, a nonzero value is returned. 4. The function is implemented with memcpy_s() because the runtime-constraint detection is almost same. Tracked-On: #4885 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -32,7 +32,7 @@ static inline bool is_space(char c)
|
||||
/* Function prototypes */
|
||||
int32_t strcmp(const char *s1_arg, const char *s2_arg);
|
||||
int32_t strncmp(const char *s1_arg, const char *s2_arg, size_t n_arg);
|
||||
char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg);
|
||||
int32_t strncpy_s(char *d, size_t dmax, const char *s, size_t slen);
|
||||
char *strchr(char *s_arg, char ch);
|
||||
size_t strnlen_s(const char *str_arg, size_t maxlen_arg);
|
||||
void *memset(void *base, uint8_t v, size_t n);
|
||||
|
||||
Reference in New Issue
Block a user