Skip to content
Snippets Groups Projects
Commit f06f261a authored by A0Dev0Knight's avatar A0Dev0Knight
Browse files

Fixed warnings.

parent e2dbe0dd
No related branches found
No related tags found
No related merge requests found
Pipeline #76115 passed
......@@ -10,21 +10,21 @@
void *malloc(size_t size)
{
/* TODO: Implement malloc(). */
int long long result = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
int long long result = (int long long)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (result < 0)
{
return NULL;
}
mem_list_add(result, size);
mem_list_add((void*)result, size);
return (void*)result;
}
void *calloc(size_t nmemb, size_t size)
{
/* TODO: Implement calloc(). */
int long long result = mmap(NULL, nmemb * size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
int long long result = (int long long)mmap(NULL, nmemb * size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (result < 0)
{
......@@ -33,8 +33,8 @@ void *calloc(size_t nmemb, size_t size)
memset((void*)result, 0, nmemb * size);
mem_list_add(result, size * nmemb);
return result;
mem_list_add((void*)result, size * nmemb);
return (void*)result;
}
void free(void *ptr)
......
......@@ -52,12 +52,19 @@ int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, i
// }
// errno = -result;
(void)fd;
(void)path;
(void)st;
(void)flag;
return -1;
}
int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag)
{
/* TODO: Implement fstatat(). Use fstatat_statx(). */
(void)fd;
(void)path;
(void)st;
(void)flag;
return -1;
}
......@@ -6,7 +6,7 @@ char *strcpy(char *destination, const char *source)
{
/* TODO: Implement strcpy(). */
char *c = destination;
char *d = source;
const char *d = source;
while (*d != '\0')
{
......@@ -44,7 +44,7 @@ char *strcat(char *destination, const char *source)
c++;
}
char *d = source;
const char *d = source;
while (*d != '\0')
{
......@@ -84,8 +84,8 @@ char *strncat(char *destination, const char *source, size_t len)
int strcmp(const char *str1, const char *str2)
{
/* TODO: Implement strcmp(). */
char *s1 = str1;
char *s2 = str2;
const char *s1 = str1;
const char *s2 = str2;
while (((*s1) - (*s2) == 0) && (*s1 != '\0') && (*s2 != '\0'))
{
......@@ -112,8 +112,8 @@ int strcmp(const char *str1, const char *str2)
int strncmp(const char *str1, const char *str2, size_t len)
{
/* TODO: Implement strncmp(). */
char *s1 = str1;
char *s2 = str2;
const char *s1 = str1;
const char *s2 = str2;
size_t offset = 0;
......@@ -162,13 +162,13 @@ size_t strlen(const char *str)
char *strchr(const char *str, int c)
{
/* TODO: Implement strchr(). */
char *d = str;
const char *d = str;
while ( *d != '\0')
{
if ((int)*d == c)
{
return d;
return (char*)d;
}
d++;
}
......@@ -179,14 +179,14 @@ char *strchr(const char *str, int c)
char *strrchr(const char *str, int c)
{
/* TODO: Implement strrchr(). */
char *d = str;
const char *d = str;
char *last = NULL;
while ( *d != '\0')
{
if ((int)*d == c)
{
last = d;
last =(char*)d;
}
d++;
}
......@@ -197,8 +197,8 @@ char *strrchr(const char *str, int c)
char *strstr(const char *haystack, const char *needle)
{
/* TODO: Implement strstr(). */
char *hay = haystack;
char * ndl = needle;
const char *hay = haystack;
const char * ndl = needle;
char *begin = NULL;
while (*hay != '\0')
......@@ -207,7 +207,7 @@ char *strstr(const char *haystack, const char *needle)
{
if (begin == NULL)
{
begin = hay;
begin = (char*)hay;
}
ndl++;
......@@ -221,7 +221,7 @@ char *strstr(const char *haystack, const char *needle)
// reset ndl to be found
ndl = needle;
begin == NULL;
begin = NULL;
}
}
......@@ -235,15 +235,15 @@ char *strstr(const char *haystack, const char *needle)
char *strrstr(const char *haystack, const char *needle)
{
/* TODO: Implement strrstr(). */
char *hay = haystack + strlen(haystack) - 1;
char * ndl = needle + strlen(needle) - 1;
const char *hay = haystack + strlen(haystack) - 1;
const char * ndl = needle + strlen(needle) - 1;
char *begin = NULL;
while (strlen(hay) != strlen(haystack))
{
if (*hay == *ndl)
{
begin = hay;
begin = (char*)hay;
ndl--;
}
else{
......@@ -255,7 +255,7 @@ char *strrstr(const char *haystack, const char *needle)
// reset ndl to be found
ndl = needle + strlen(needle) - 1;
begin == NULL;
begin = NULL;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment