mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
Xcode warnings.
This commit is contained in:
parent
175f047e15
commit
62a379d0a0
@ -4,12 +4,15 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef MAP_TO_EDK_STRLEN
|
||||
extern "C" UINTN EFIAPI AsciiStrLen (IN CONST CHAR8 *String);
|
||||
#endif
|
||||
|
||||
// Hope that unsigned long long is as big in bits sa a pointer difference.
|
||||
|
||||
#define DOWN_CAST_TO_SIZE_T(a) ( (ptrdiff_t)(a) > (ptrdiff_t)(SIZE_T_MAX) ? abort(), 0 : (size_t)(a) )
|
||||
|
||||
/* Return the length of the null-terminated string STR. Scan for
|
||||
the null terminator quickly by testing four bytes at a time. */
|
||||
size_t strlen (const char *str)
|
||||
@ -28,8 +31,7 @@ size_t strlen (const char *str)
|
||||
& (sizeof (longword) - 1)) != 0;
|
||||
++char_ptr)
|
||||
if (*char_ptr == '\0') {
|
||||
if ( char_ptr - str > SIZE_T_MAX ) abort();
|
||||
return (size_t)(char_ptr - str);
|
||||
return DOWN_CAST_TO_SIZE_T(char_ptr - str);
|
||||
}
|
||||
|
||||
/* All these elucidatory comments refer to 4-byte longwords,
|
||||
@ -73,23 +75,23 @@ size_t strlen (const char *str)
|
||||
const char *cp = (const char *) (longword_ptr - 1);
|
||||
|
||||
if (cp[0] == 0)
|
||||
return cp - str;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str);
|
||||
if (cp[1] == 0)
|
||||
return cp - str + 1;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 1);
|
||||
if (cp[2] == 0)
|
||||
return cp - str + 2;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 2);
|
||||
if (cp[3] == 0)
|
||||
return cp - str + 3;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 3);
|
||||
if (sizeof (longword) > 4)
|
||||
{
|
||||
if (cp[4] == 0)
|
||||
return cp - str + 4;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 4);
|
||||
if (cp[5] == 0)
|
||||
return cp - str + 5;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 5);
|
||||
if (cp[6] == 0)
|
||||
return cp - str + 6;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 6);
|
||||
if (cp[7] == 0)
|
||||
return cp - str + 7;
|
||||
return DOWN_CAST_TO_SIZE_T(cp - str + 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user