hv: remove strcpy_s

Since it's discarded.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
This commit is contained in:
Li, Fei1 2018-12-12 20:18:43 +08:00 committed by wenlingz
parent 29c8494fd0
commit b8ca17c6da
2 changed files with 0 additions and 74 deletions

View File

@ -24,7 +24,6 @@ void udelay(uint32_t us);
void *memchr(const void *void_s, int32_t c, size_t n);
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 *strcpy_s(char *d_arg, size_t dmax, const char *s_arg);
char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg);
char *strchr(char *s_arg, char ch);
size_t strnlen_s(const char *str_arg, size_t maxlen_arg);

View File

@ -172,79 +172,6 @@ char *strchr(char *s_arg, char ch)
return ((*s) != '\0') ? s : NULL;
}
/**
*strcpy_s
*
* description:
* This function copies the string pointed to by s to a buffer
* pointed by d.
*
* input:
* d pointer to dest buffer.
*
* dmax maximum length of dest buffer
*
* s pointer to the source string
*
* return value:
* dest pointer to dest string if string is copied
* successfully,or else return null.
*
* notes:
* 1) both d and s shall not be null pointers.
* 2) dmax shall not 0.
*/
char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg)
{
char *d = d_arg;
const char *s = s_arg;
char *dest_base;
size_t dest_avail;
uint64_t overlap_guard;
if ((s == NULL) || (d == NULL) || (dmax == 0U)) {
pr_err("%s: invalid src, dest buffer or length.", __func__);
return NULL;
}
if (s == d) {
return d;
}
overlap_guard = (uint64_t)((d > s) ? (d - s - 1) : (s - d - 1));
dest_avail = dmax;
dest_base = d;
while (dest_avail > 0U) {
if (overlap_guard == 0U) {
pr_err("%s: overlap happened.", __func__);
d--;
*d = '\0';
return NULL;
}
*d = *s;
if (*d == '\0') {
return dest_base;
}
d++;
s++;
dest_avail--;
overlap_guard--;
}
pr_err("%s: dest buffer has no enough space.", __func__);
/*
* to avoid a string that is not
* null-terminated in dest buffer
*/
dest_base[dmax - 1] = '\0';
return NULL;
}
/*
* strncpy_s
*