Fix libc compile warnings.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-26 16:57:19 +02:00
parent 4cb4478529
commit 7fc1f0011a
11 changed files with 34 additions and 21 deletions

View File

@ -29,6 +29,8 @@
// TODO: Implement this in the kernel.
extern "C" int chmod(const char* path, mode_t mode)
{
(void) path;
(void) mode;
errno = ENOSYS;
return -1;
}

View File

@ -29,6 +29,7 @@ static const char* dlerrormsg = NULL;
extern "C" void* dlopen(const char* filename, int mode)
{
(void) mode;
dlerrormsg = "Sortix does not yet support dynamic linking";
fprintf(stderr, "%s: loading file: %s\n", dlerrormsg, filename);
return NULL;
@ -36,6 +37,7 @@ extern "C" void* dlopen(const char* filename, int mode)
extern "C" void* dlsym(void* handle, const char* name)
{
(void) handle;
dlerrormsg = "Sortix does not yet support dynamic linking";
fprintf(stderr, "%s: resolving symbol: %s\n", dlerrormsg, name);
return NULL;
@ -43,12 +45,13 @@ extern "C" void* dlsym(void* handle, const char* name)
extern "C" int dlclose(void* handle)
{
(void) handle;
return 0;
}
extern "C" char* dlerror(void* handle)
extern "C" char* dlerror()
{
const char* result = dlerrormsg;
dlerrormsg = NULL;
return (char*) dlerrormsg;
return (char*) result;
}

View File

@ -29,6 +29,8 @@
// TODO: Implement this in the kernel.
extern "C" int fchmod(int fd, mode_t mode)
{
(void) fd;
(void) mode;
errno = ENOSYS;
return -1;
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
This file is part of the Sortix C Library.
@ -28,7 +28,8 @@
extern "C" int fputs(const char* str, FILE* fp)
{
size_t stringlen = strlen(str);
int result = fwrite(str, 1, stringlen, fp);
if ( result < stringlen ) { return EOF; }
size_t result = fwrite(str, 1, stringlen, fp);
if ( result < stringlen )
return EOF;
return result;
}

View File

@ -375,6 +375,7 @@ static void InsertChunk(Chunk* chunk)
assert(chunk->IsSane());
}
__attribute__((unused))
static bool ValidateHeap()
{
bool foundbin[NUMBINS];
@ -524,7 +525,6 @@ extern "C" void* malloc(size_t size)
chunk->size -= left;
chunk->GetTrailer()->size = chunk->size;
size_t leftbinindex = BSR(left);
Chunk* leftchunk = chunk->RightNeighbor();
leftchunk->size = left;
Trailer* lefttrailer = leftchunk->GetTrailer();

View File

@ -35,7 +35,7 @@ __BEGIN_DECLS
#define RTLD_LOCAL 0 /* Bit 8 is not set. */
int dlclose(void* handle);
char* dlerror(void* handle);
char* dlerror();
void* dlopen(const char* filename, int mode);
void* dlsym(void* handle, const char* name);

View File

@ -29,7 +29,6 @@
static char* Substring(const char* src, size_t offset, size_t length)
{
size_t srclen = strlen(src);
char* dest = new char[length + 1];
if ( !dest ) { return NULL; }
memcpy(dest, src + offset, length * sizeof(char));

View File

@ -28,12 +28,15 @@
void longjmp(jmp_buf env, int val)
{
(void) env;
(void) val;
fprintf(stderr, "setjmp(3) and longjmp(3) are unimplemented, abort!\n");
abort();
}
int setjmp(jmp_buf env)
{
(void) env;
return 0;
}

View File

@ -30,5 +30,6 @@
// TODO: Implement this in the kernel.
extern "C" mode_t umask(mode_t mask)
{
(void) mask;
return 0;
}

View File

@ -28,6 +28,8 @@
extern "C" int utime(const char* filepath, const struct utimbuf* times)
{
(void) filepath;
(void) times;
// TODO: Sure, I did that! There is no kernel support for this yet.
return 0;
}

View File

@ -75,25 +75,25 @@ extern "C" int vfscanf(FILE* fp, const char* origformat, va_list ap)
union { const char* format; const unsigned char* formatuc; };
format = origformat;
int matcheditems = 0;
size_t fieldwidth;
size_t fieldwidth = 0;
bool escaped = false;
bool discard;
bool negint;
bool intunsigned;
bool leadingzero;
bool hasprefix;
bool string;
size_t intparsed;
uintmax_t intvalue;
bool discard = false;
bool negint = false;
bool intunsigned = false;
bool leadingzero = false;
bool hasprefix = false;
bool string = false;
size_t intparsed = 0;
uintmax_t intvalue = 0;
int ic;
int base;
int base = 0;
int cval;
const size_t UNDO_MAX = 4;
int undodata[UNDO_MAX];
size_t undoable = 0;
size_t strwritten;
char* strdest;
enum scantype scantype;
size_t strwritten = 0;
char* strdest = NULL;
enum scantype scantype = TYPE_INT;
enum scanmode scanmode = MODE_INIT;
while ( true )
{