-Wextra warnings fixed

This commit is contained in:
2023-03-15 16:54:36 +06:00
parent a200f2c965
commit a6a6d2d4ae
12 changed files with 23 additions and 18 deletions

View File

@@ -50,7 +50,7 @@ bool cptr_endsWith(char* ptr, char* fragment){
u32 cptr_indexOf(char* ptr, char* fragment){
char sc=*ptr;
for(i32 si=0, fi=0; sc!=0; si++){
for(u32 si=0, fi=0; sc!='\0'; si++){
sc=ptr[si];
if(sc==fragment[fi]){
fi++;
@@ -63,7 +63,7 @@ u32 cptr_indexOf(char* ptr, char* fragment){
}
u32 cptr_indexOfChar(char* ptr, char fragment){
char sc=*ptr;
for(i32 si=0; sc!=0; si++){
for(u32 si=0; sc!='\0'; si++){
sc=ptr[si];
if(sc==fragment){
return si;
@@ -73,7 +73,7 @@ u32 cptr_indexOfChar(char* ptr, char fragment){
}
u32 cptr_lastIndexOf(char* ptr, char* fragment){
char sc=*ptr;
i32 fi_last=cptr_length(fragment)-1;
u32 fi_last=cptr_length(fragment)-1;
for(i32 si=cptr_length(ptr)-1, fi=fi_last; si>=0; si--){
sc=ptr[si];
if(sc==fragment[fi]){
@@ -103,7 +103,7 @@ void memcopy(void* from, void* to, u32 size){
((char*)to)[i]=((char*)from)[i];
}
char* __cptr_concat(u16 n, ...){
char* __cptr_concat(u32 n, ...){
char** strs=(char**)malloc(n*sizeof(char*));
u32* lengths=malloc(n*sizeof(u32));
u32 totalLength=0;

View File

@@ -44,7 +44,7 @@ static inline bool cptr_contains(char* ptr, char* fragment){
void memcopy(void* from, void* to, u32 size);
char* __cptr_concat(u16 n, ...);
char* __cptr_concat(u32 n, ...);
#define cptr_concat(STR...) __cptr_concat(count_args(STR), STR)
#if __cplusplus

View File

@@ -116,8 +116,9 @@ You can even embed it into macro in header (see kprint.h)
#define PRAGMA_WARNING_DISABLE(wName) _PRAGMA(GCC diagnostic ignored wName)
#define PRAGMA_WARNING_POP _PRAGMA(GCC diagnostic pop)
#define W_INT_CONVERSION "-Wint-conversion"
#define W_IMPLICIT_FALLTHROUGH "-Wimplicit-fallthrough"
#endif
#define WARNING_DISABLE(WARNING, CODE) \
#define WARNING_DISABLE(WARNING, CODE...) \
PRAGMA_WARNING_PUSH \
PRAGMA_WARNING_DISABLE(WARNING) \
CODE; \

View File

@@ -113,7 +113,7 @@ char* toString_bin(void* _bytes, u32 size, bool inverse, bool withPrefix){
for(i32 bn=size-1; bn>=0; bn--)
byte_to_bits(bytes[bn])
} else {
for(i32 bn=0; bn<size; bn++)
for(u32 bn=0; bn<size; bn++)
byte_to_bits(bytes[bn])
}
str[cn]=0;
@@ -155,7 +155,7 @@ char* toString_hex(void* _bytes, u32 size, bool inverse, bool withPrefix, bool u
}
// right to left
else {
for(i32 bn=0; bn<size; bn++){ // byte number
for(u32 bn=0; bn<size; bn++){ // byte number
unsigned char byte=bytes[bn];
str[cn++]=_4bitsHex(byte/16, uppercase);
str[cn++]=_4bitsHex(byte%16, uppercase);