Skip to content

Commit b8ca17c

Browse files
lifeixwenlingz
authored andcommitted
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>
1 parent 29c8494 commit b8ca17c

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

hypervisor/include/lib/rtl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ void udelay(uint32_t us);
2424
void *memchr(const void *void_s, int32_t c, size_t n);
2525
int32_t strcmp(const char *s1_arg, const char *s2_arg);
2626
int32_t strncmp(const char *s1_arg, const char *s2_arg, size_t n_arg);
27-
char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg);
2827
char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg);
2928
char *strchr(char *s_arg, char ch);
3029
size_t strnlen_s(const char *str_arg, size_t maxlen_arg);

hypervisor/lib/string.c

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -172,79 +172,6 @@ char *strchr(char *s_arg, char ch)
172172
return ((*s) != '\0') ? s : NULL;
173173
}
174174

175-
/**
176-
*strcpy_s
177-
*
178-
* description:
179-
* This function copies the string pointed to by s to a buffer
180-
* pointed by d.
181-
*
182-
* input:
183-
* d pointer to dest buffer.
184-
*
185-
* dmax maximum length of dest buffer
186-
*
187-
* s pointer to the source string
188-
*
189-
* return value:
190-
* dest pointer to dest string if string is copied
191-
* successfully,or else return null.
192-
*
193-
* notes:
194-
* 1) both d and s shall not be null pointers.
195-
* 2) dmax shall not 0.
196-
*/
197-
char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg)
198-
{
199-
char *d = d_arg;
200-
const char *s = s_arg;
201-
char *dest_base;
202-
size_t dest_avail;
203-
uint64_t overlap_guard;
204-
205-
if ((s == NULL) || (d == NULL) || (dmax == 0U)) {
206-
pr_err("%s: invalid src, dest buffer or length.", __func__);
207-
return NULL;
208-
}
209-
210-
if (s == d) {
211-
return d;
212-
}
213-
214-
overlap_guard = (uint64_t)((d > s) ? (d - s - 1) : (s - d - 1));
215-
216-
dest_avail = dmax;
217-
dest_base = d;
218-
219-
while (dest_avail > 0U) {
220-
if (overlap_guard == 0U) {
221-
pr_err("%s: overlap happened.", __func__);
222-
d--;
223-
*d = '\0';
224-
return NULL;
225-
}
226-
227-
*d = *s;
228-
if (*d == '\0') {
229-
return dest_base;
230-
}
231-
232-
d++;
233-
s++;
234-
dest_avail--;
235-
overlap_guard--;
236-
}
237-
238-
pr_err("%s: dest buffer has no enough space.", __func__);
239-
240-
/*
241-
* to avoid a string that is not
242-
* null-terminated in dest buffer
243-
*/
244-
dest_base[dmax - 1] = '\0';
245-
return NULL;
246-
}
247-
248175
/*
249176
* strncpy_s
250177
*

0 commit comments

Comments
 (0)