From: John Hodge (sonata) Date: Tue, 13 Nov 2012 03:59:00 +0000 (+0800) Subject: Misc - Changes to allow warning-less compilation with clang X-Git-Tag: rel0.15~661 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ea8e0fad3dfc8bf735d41eedbad2a8e6198059aa;p=tpg%2Facess2.git Misc - Changes to allow warning-less compilation with clang --- diff --git a/KernelLand/Kernel/binary.c b/KernelLand/Kernel/binary.c index a15db0bf..208ab95b 100644 --- a/KernelLand/Kernel/binary.c +++ b/KernelLand/Kernel/binary.c @@ -194,7 +194,7 @@ int Proc_SysSpawn(const char *Binary, const char **ArgV, const char **EnvP, int Proc_Execve(Binary, ArgV, EnvP, size); for(;;); } - if( ret < 0 ) + if( ret == -1 ) { VFS_FreeSavedHandles(nFD, handles); free(cachebuf); diff --git a/KernelLand/Kernel/lib.c b/KernelLand/Kernel/lib.c index 36b877c3..5f302d4f 100644 --- a/KernelLand/Kernel/lib.c +++ b/KernelLand/Kernel/lib.c @@ -287,23 +287,23 @@ Sint64 timestamp(int sec, int min, int hrs, int day, int month, int year) return stamp * 1000; } +static Sint64 DivMod64(Sint64 N, Sint64 D, Sint64 *R); + +static Sint64 DivMod64(Sint64 N, Sint64 D, Sint64 *R) +{ + int sign = (N < 0) != (D < 0); + if(N < 0) N = -N; + if(D < 0) D = -D; + if(sign) + return -DivMod64U(N, D, (Uint64*)R); + else + return DivMod64U(N, D, (Uint64*)R); +} + void format_date(tTime TS, int *year, int *month, int *day, int *hrs, int *mins, int *sec, int *ms) { int is_leap = 0, i; - auto Sint64 DivMod64(Sint64 N, Sint64 D, Sint64 *R); - - Sint64 DivMod64(Sint64 N, Sint64 D, Sint64 *R) - { - int sign = (N < 0) != (D < 0); - if(N < 0) N = -N; - if(D < 0) D = -D; - if(sign) - return -DivMod64U(N, D, (Uint64*)R); - else - return DivMod64U(N, D, (Uint64*)R); - } - // Get time // TODO: Leap-seconds? { diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index ef944267..ea705795 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -184,7 +184,12 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad) /** * \brief Append a character the the vsnprintf output */ -#define PUTCH(c) _putch(c) +#define PUTCH(ch) do { \ + if(pos < __maxlen) { \ + if(__s) __s[pos] = ch; \ + } \ + pos ++; \ + } while(0) #define GETVAL() do {\ if(isLongLong) val = va_arg(args, Uint64);\ else val = va_arg(args, unsigned int);\ @@ -203,17 +208,6 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) size_t pos = 0; // Flags int bPadLeft = 0; - - auto void _putch(char ch); - - void _putch(char ch) - { - if(pos < __maxlen) - { - if(__s) __s[pos] = ch; - } - pos ++; - } while((c = *__format++) != 0) { diff --git a/KernelLand/Modules/USB/Core/usb.c b/KernelLand/Modules/USB/Core/usb.c index 3234a778..eb1aa391 100644 --- a/KernelLand/Modules/USB/Core/usb.c +++ b/KernelLand/Modules/USB/Core/usb.c @@ -31,7 +31,7 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) { tUSBHost *host; - host = malloc(sizeof(tUSBHost) + nPorts*sizeof(tUSBHubPort)); + host = malloc(sizeof(tUSBHost) + sizeof(tUSBDevice) + sizeof(tUSBInterface) + nPorts*sizeof(tUSBHubPort)); if(!host) { // Oh, bugger. return NULL; @@ -40,19 +40,21 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) host->Ptr = ControllerPtr; memset(host->AddressBitmap, 0, sizeof(host->AddressBitmap)); - host->RootHubDev.ParentHub = NULL; - host->RootHubDev.Host = host; - host->RootHubDev.Address = 0; + host->RootHubDev = (void*)(host + 1); + host->RootHubDev->ParentHub = NULL; + host->RootHubDev->Host = host; + host->RootHubDev->Address = 0; ASSERT(HostDef->InitControl); - host->RootHubDev.EndpointHandles[0] = HostDef->InitControl(ControllerPtr, 0, 64); + host->RootHubDev->EndpointHandles[0] = HostDef->InitControl(ControllerPtr, 0, 64); -// host->RootHubIf.Next = NULL; - host->RootHubIf.Dev = &host->RootHubDev; - host->RootHubIf.Driver = NULL; - host->RootHubIf.Data = NULL; - host->RootHubIf.nEndpoints = 0; + host->RootHubIf = (void*)(host->RootHubDev + 1); +// host->RootHubIf->Next = NULL; + host->RootHubIf->Dev = host->RootHubDev; + host->RootHubIf->Driver = NULL; + host->RootHubIf->Data = NULL; + host->RootHubIf->nEndpoints = 0; - host->RootHub.Interface = &host->RootHubIf; + host->RootHub.Interface = host->RootHubIf; host->RootHub.nPorts = nPorts; memset(host->RootHub.Ports, 0, sizeof(tUSBHubPort)*nPorts); diff --git a/KernelLand/Modules/USB/Core/usb.h b/KernelLand/Modules/USB/Core/usb.h index c5c8cad6..2de69859 100644 --- a/KernelLand/Modules/USB/Core/usb.h +++ b/KernelLand/Modules/USB/Core/usb.h @@ -101,8 +101,8 @@ struct sUSBHost Uint8 AddressBitmap[128/8]; - tUSBDevice RootHubDev; - tUSBInterface RootHubIf; + tUSBDevice *RootHubDev; + tUSBInterface *RootHubIf; tUSBHub RootHub; }; diff --git a/KernelLand/Modules/USB/Core/usb_lowlevel.c b/KernelLand/Modules/USB/Core/usb_lowlevel.c index 57948cec..27bad3e1 100644 --- a/KernelLand/Modules/USB/Core/usb_lowlevel.c +++ b/KernelLand/Modules/USB/Core/usb_lowlevel.c @@ -84,7 +84,7 @@ void USB_int_WakeThread(void *Thread, void *Data, size_t Length) int USB_int_SendSetupSetAddress(tUSBHost *Host, int Address) { - USB_int_Request(&Host->RootHubDev, 0, 0x00, 5, Address & 0x7F, 0, 0, NULL); + USB_int_Request(Host->RootHubDev, 0, 0x00, 5, Address & 0x7F, 0, 0, NULL); return 0; } diff --git a/Usermode/Libraries/ld-acess.so_src/elf.c b/Usermode/Libraries/ld-acess.so_src/elf.c index 0b3656b2..4a87896d 100644 --- a/Usermode/Libraries/ld-acess.so_src/elf.c +++ b/Usermode/Libraries/ld-acess.so_src/elf.c @@ -214,7 +214,6 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) char *dynstrtab = NULL; // .dynamic String Table Elf32_Sym *dynsymtab; int (*do_relocate)(uint32_t t_info, uint32_t *ptr, Elf32_Addr addend, int Type, int bRela, const char *Sym, intptr_t iBaseDiff); - auto int _doRelocate(uint32_t r_info, uint32_t *ptr, int bRela, Elf32_Addr addend); DEBUGS("ElfRelocate: (Base=0x%x)", Base); @@ -363,14 +362,6 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) DEBUGS(" elf_relocate: Beginning Relocation"); - int _doRelocate(uint32_t r_info, uint32_t *ptr, int bRela, Elf32_Addr addend) - { - int type = ELF32_R_TYPE(r_info); - int sym = ELF32_R_SYM(r_info); - const char *symname = dynstrtab + dynsymtab[sym].nameOfs; - return do_relocate(r_info, ptr, addend, type, bRela, symname, iBaseDiff); - } - switch(hdr->machine) { case EM_386: @@ -389,6 +380,10 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) int fail = 0; + #define _doRelocate(r_info, ptr, bRela, addend) \ + do_relocate(r_info, ptr, addend, ELF32_R_TYPE(r_info), bRela, \ + dynstrtab + dynsymtab[ELF32_R_SYM(r_info)].nameOfs, iBaseDiff); + // Parse Relocation Entries if(rel && relSz) { @@ -461,6 +456,8 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) return NULL; } + #undef _doRelocate + DEBUGS("ElfRelocate: RETURN 0x%x to %p", hdr->entrypoint + iBaseDiff, __builtin_return_address(0)); return (void*)(intptr_t)( hdr->entrypoint + iBaseDiff ); }