Misc - Changes to allow warning-less compilation with clang
authorJohn Hodge (sonata) <[email protected]>
Tue, 13 Nov 2012 03:59:00 +0000 (11:59 +0800)
committerJohn Hodge (sonata) <[email protected]>
Tue, 13 Nov 2012 03:59:00 +0000 (11:59 +0800)
KernelLand/Kernel/binary.c
KernelLand/Kernel/lib.c
KernelLand/Kernel/libc.c
KernelLand/Modules/USB/Core/usb.c
KernelLand/Modules/USB/Core/usb.h
KernelLand/Modules/USB/Core/usb_lowlevel.c
Usermode/Libraries/ld-acess.so_src/elf.c

index a15db0b..208ab95 100644 (file)
@@ -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);
index 36b877c..5f302d4 100644 (file)
@@ -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?
        {
index ef94426..ea70579 100644 (file)
@@ -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)
        {
index 3234a77..eb1aa39 100644 (file)
@@ -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);
 
index c5c8cad..2de6985 100644 (file)
@@ -101,8 +101,8 @@ struct sUSBHost
        
        Uint8   AddressBitmap[128/8];
        
-       tUSBDevice      RootHubDev;
-       tUSBInterface   RootHubIf;
+       tUSBDevice      *RootHubDev;
+       tUSBInterface   *RootHubIf;
        tUSBHub RootHub;
 };
 
index 57948ce..27bad3e 100644 (file)
@@ -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;
 }
 
index 0b3656b..4a87896 100644 (file)
@@ -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 );
 }

UCC git Repository :: git.ucc.asn.au