Apply clang-format for core/shared and product-mini files (#785)

Apply clang-format for core/shared and product-mini files
This commit is contained in:
Wenyong Huang
2021-10-14 09:12:07 +08:00
committed by GitHub
parent fb4afc7ca4
commit 17f62ad472
107 changed files with 3436 additions and 2898 deletions

View File

@ -12,70 +12,67 @@
#define RSIZE_MAX 0x7FFFFFFF
int
b_memcpy_s(void * s1, unsigned int s1max,
const void * s2, unsigned int n)
b_memcpy_s(void *s1, unsigned int s1max, const void *s2, unsigned int n)
{
char *dest = (char*)s1;
char *src = (char*)s2;
if (n == 0) {
char *dest = (char *)s1;
char *src = (char *)s2;
if (n == 0) {
return 0;
}
if (s1 == NULL || s1max > RSIZE_MAX) {
return -1;
}
if (s2 == NULL || n > s1max) {
memset(dest, 0, s1max);
return -1;
}
memcpy(dest, src, n);
return 0;
}
if (s1 == NULL || s1max > RSIZE_MAX) {
return -1;
}
if (s2 == NULL || n > s1max) {
memset(dest, 0, s1max);
return -1;
}
memcpy(dest, src, n);
return 0;
}
int b_memmove_s(void * s1, unsigned int s1max,
const void * s2, unsigned int n)
{
char *dest = (char*)s1;
char *src = (char*)s2;
if (n == 0) {
return 0;
}
if (s1 == NULL || s1max > RSIZE_MAX) {
return -1;
}
if (s2 == NULL || n > s1max) {
memset(dest, 0, s1max);
return -1;
}
memmove(dest, src, n);
return 0;
}
int
b_strcat_s(char * s1, unsigned int s1max, const char * s2)
b_memmove_s(void *s1, unsigned int s1max, const void *s2, unsigned int n)
{
if (NULL == s1 || NULL == s2
|| s1max < (strlen(s1) + strlen(s2) + 1)
|| s1max > RSIZE_MAX) {
return -1;
}
char *dest = (char *)s1;
char *src = (char *)s2;
if (n == 0) {
return 0;
}
memcpy(s1 + strlen(s1), s2, strlen(s2) + 1);
return 0;
if (s1 == NULL || s1max > RSIZE_MAX) {
return -1;
}
if (s2 == NULL || n > s1max) {
memset(dest, 0, s1max);
return -1;
}
memmove(dest, src, n);
return 0;
}
int
b_strcpy_s(char * s1, unsigned int s1max, const char * s2)
b_strcat_s(char *s1, unsigned int s1max, const char *s2)
{
if (NULL == s1 || NULL == s2
|| s1max < (strlen(s2) + 1)
|| s1max > RSIZE_MAX) {
return -1;
}
if (NULL == s1 || NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1)
|| s1max > RSIZE_MAX) {
return -1;
}
memcpy(s1, s2, strlen(s2) + 1);
return 0;
memcpy(s1 + strlen(s1), s2, strlen(s2) + 1);
return 0;
}
int
b_strcpy_s(char *s1, unsigned int s1max, const char *s2)
{
if (NULL == s1 || NULL == s2 || s1max < (strlen(s2) + 1)
|| s1max > RSIZE_MAX) {
return -1;
}
memcpy(s1, s2, strlen(s2) + 1);
return 0;
}
char *
@ -105,4 +102,3 @@ wa_strdup(const char *s)
}
return s1;
}