summaryrefslogtreecommitdiff
path: root/LibC
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-23 13:00:53 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-23 13:00:53 +0200
commit58240fdb337a3ca0e2a8e63212cae509cda38daf (patch)
tree38747e507f7a7301a1fd0b7a31a4ce1d8cd8bf66 /LibC
parent243e1d84627c20a39f5464bb61cafae9fa2fe456 (diff)
downloadserenity-58240fdb337a3ca0e2a8e63212cae509cda38daf.zip
Do a pass of compiler warning fixes.
This is really making me question not using 64-bit integers more.
Diffstat (limited to 'LibC')
-rw-r--r--LibC/stdio.cpp2
-rw-r--r--LibC/stdlib.cpp4
-rw-r--r--LibC/string.cpp6
-rw-r--r--LibC/unistd.cpp2
4 files changed, 8 insertions, 6 deletions
diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp
index 25096819d3..12a33092ca 100644
--- a/LibC/stdio.cpp
+++ b/LibC/stdio.cpp
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <AK/printf.cpp>
+#include <AK/StdLibExtras.h>
#include <Kernel/Syscall.h>
extern "C" {
@@ -405,6 +406,7 @@ FILE* freopen(const char* pathname, const char* mode, FILE* stream)
FILE* fdopen(int fd, const char* mode)
{
+ UNUSED_PARAM(mode);
// FIXME: Verify that the mode matches how fd is already open.
if (fd < 0)
return nullptr;
diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp
index 07096155a3..ecc57f6cad 100644
--- a/LibC/stdlib.cpp
+++ b/LibC/stdlib.cpp
@@ -133,7 +133,7 @@ void free(void* ptr)
return;
}
- for (unsigned i = header->first_chunk_index; i < (header->first_chunk_index + header->chunk_count); ++i)
+ for (int i = header->first_chunk_index; i < (header->first_chunk_index + header->chunk_count); ++i)
s_malloc_map[i / 8] &= ~(1 << (i % 8));
s_malloc_sum_alloc -= header->chunk_count * CHUNK_SIZE;
@@ -473,7 +473,7 @@ long strtol(const char* str, char** endptr, int base)
} else if (neg)
acc = -acc;
if (endptr)
- *endptr = (char*)(any ? s - 1 : str);
+ *endptr = const_cast<char*>((any ? s - 1 : str));
return acc;
}
diff --git a/LibC/string.cpp b/LibC/string.cpp
index eed302db5f..3b84340d62 100644
--- a/LibC/string.cpp
+++ b/LibC/string.cpp
@@ -202,10 +202,10 @@ char* strchr(const char* str, int c)
void* memchr(const void* ptr, int c, size_t size)
{
char ch = c;
- char* cptr = (char*)ptr;
+ auto* cptr = (const char*)ptr;
for (size_t i = 0; i < size; ++i) {
if (cptr[i] == ch)
- return cptr + i;
+ return const_cast<char*>(cptr + i);
}
return nullptr;
}
@@ -358,7 +358,7 @@ char* strpbrk(const char* s, const char* accept)
{
while (*s)
if(strchr(accept, *s++))
- return (char*)--s;
+ return const_cast<char*>(--s);
return nullptr;
}
diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp
index 5cba9f33ae..28190bdbfd 100644
--- a/LibC/unistd.cpp
+++ b/LibC/unistd.cpp
@@ -83,7 +83,7 @@ int execl(const char* filename, const char* arg0, ...)
}
va_end(ap);
args.append(nullptr);
- return execve(filename, (char* const *)args.data(), environ);
+ return execve(filename, const_cast<char* const*>(args.data()), environ);
}
uid_t getuid()