Fixing bugs exposed by scan-build
authorJohn Hodge <[email protected]>
Sun, 15 Jan 2012 10:43:26 +0000 (18:43 +0800)
committerJohn Hodge <[email protected]>
Sun, 15 Jan 2012 10:43:26 +0000 (18:43 +0800)
12 files changed:
BuildConf/host/Makefile.cfg
Kernel/arch/x86/mm_phys.c
Kernel/heap.c
Modules/IPStack/tcp.c
Usermode/Applications/axwin3_src/Makefile
Usermode/Applications/axwin3_src/WM/decorator.c
Usermode/Applications/axwin3_src/WM/renderers/widget.c
Usermode/Applications/axwin3_src/WM/wm_input.c
Usermode/Applications/axwin3_src/WM/wm_render_text.c
Usermode/Applications/ping_src/main.c
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/ld-acess.so_src/Makefile

index 2f8488a..057e96e 100644 (file)
@@ -10,9 +10,13 @@ include $(ACESSDIR)/BuildConf/$(HOST_ARCH)/Makefile.cfg
 
 OBJDUMP := objdump -S
 
-CC := $(SAVED_CC_)
+CC_SUFFIX = 
+
 ifeq ($(HOST_ARCH),x86)
-CC += -m32
+CC_SUFFIX := -m32
+LD_SUFFIX := -melf_i386
 endif
-LD := $(SAVED_LD_)
+
+CC := $(SAVED_CC_) $(CC_SUFFIX)
+LD := $(SAVED_LD_) $(LD_SUFFIX)
 
index 81edcf2..aa1b260 100644 (file)
@@ -135,8 +135,8 @@ tPAddr MM_AllocPhys(void)
         int    first, last;
        for( i = numAddrClasses; i -- > 1; )
        {
-               first = 1 << (addrClasses[i-1] - 12);
-               last = (1 << (addrClasses[i] - 12)) - 1;
+               first = 1UL << (addrClasses[i-1] - 12);
+               last = (1UL << (addrClasses[i] - 12)) - 1;
                // Range is above the last free page
                if( first > giLastPossibleFree )
                        continue;
index 921cc6b..eefd13c 100644 (file)
@@ -68,7 +68,7 @@ void *Heap_Extend(int Bytes)
        
        // Bounds Check
        if( (tVAddr)gHeapEnd + ((Bytes+0xFFF)&~0xFFF) > MM_KHEAP_MAX ) {
-               Bytes = MM_KHEAP_MAX - (tVAddr)gHeapEnd;
+//             Bytes = MM_KHEAP_MAX - (tVAddr)gHeapEnd;
                return NULL;
        }
        
index bb71fdb..e2cc4a8 100644 (file)
@@ -764,7 +764,7 @@ Uint16 TCP_GetUnusedPort()
 
        // Get Next outbound port
        ret = giTCP_NextOutPort++;
-       while( gaTCP_PortBitmap[ret/32] & (1 << (ret%32)) )
+       while( gaTCP_PortBitmap[ret/32] & (1UL << (ret%32)) )
        {
                ret ++;
                giTCP_NextOutPort++;
index caa174d..2ed5bce 100644 (file)
@@ -9,14 +9,14 @@ SUBMAKE = $(MAKE) --no-print-directory
 
 .PNONY: all install clean $(FILES)
 
-all:
+all: $(FILES)
        @$(foreach DIR,$(DIRS), echo --- $(NAME)/$(DIR) && $(SUBMAKE) -C $(DIR) $@ &&) true
-install:
+install: $(FILES)
        @$(xMKDIR) $(DISTROOT)/Apps ; true
        @$(xMKDIR) $(DISTROOT)/Apps/AxWin ; true
        @$(xMKDIR) $(DISTROOT)/Apps/3.0 ; true
        @$(foreach DIR,$(DIRS), echo --- $(NAME)/$(DIR) && $(SUBMAKE) -C $(DIR) $@ &&) true
-       @$(foreach FILE,$(FILES), $(SUBMAKE) $FILE;) true
+#      @$(foreach FILE,$(FILES), $(SUBMAKE) -C $(FILE);) true
 
 clean:
        @$(foreach DIR,$(DIRS), $(SUBMAKE) -C $(DIR) $@ &&) true
index 937fb18..6239b76 100644 (file)
@@ -48,7 +48,7 @@ void Decorator_UpdateBorderSize(tWindow *Window)
 
 void Decorator_Redraw(tWindow *Window)
 {
-        int    bActive;
+        int    bActive = 0;
         int    text_width, text_height;
        
        // TODO: This could possibly be expensive, but is there a better way?
index 586a506..7668cbd 100644 (file)
@@ -392,7 +392,7 @@ tElement *Widget_GetElementByPos(tWidgetWin *Info, int X, int Y)
        tElement        *ret, *next, *ele;
        
        next = &Info->RootElement;
-       while(next)
+       do
        {
                ret = next;
                next = NULL;
@@ -405,7 +405,7 @@ tElement *Widget_GetElementByPos(tWidgetWin *Info, int X, int Y)
                        if(Y >= ele->CachedY + ele->CachedH)    continue;
                        next = ele;
                }
-       }
+       } while(next);
        return ret;
 }
 
index 1fc49f8..3220f77 100644 (file)
@@ -22,7 +22,7 @@ tWindow       *gpWM_DownStartWindow[MAX_BUTTONS];
 // === CODE ===
 tWindow *WM_int_GetWindowAtPos(int X, int Y)
 {
-       tWindow *win, *next_win, *ret;
+       tWindow *win, *next_win, *ret = NULL;
        
        next_win = gpWM_RootWindow;
 
index d189e5e..8168c5c 100644 (file)
@@ -171,7 +171,7 @@ tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint)
                                 prev = next, next = next->Next
                                 );
                        
-                       if( next->Codepoint == Codepoint )
+                       if( next && next->Codepoint == Codepoint )
                                return next;
                        
                }
@@ -185,7 +185,7 @@ tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint)
                                 prev && prev->Codepoint > Codepoint;
                                 next = prev, prev = prev->Prev
                                 );
-                       if( prev->Codepoint == Codepoint )
+                       if( prev && prev->Codepoint == Codepoint )
                                return prev;
                }
        }
index 4c8c84d..4be3306 100644 (file)
@@ -14,7 +14,6 @@
 // === PROTOTYPES ===
 void   PrintUsage(char *ProgName);
 void   PrintHelp(char *ProgName);
- int   GetAddress( char *Address, uint8_t *Addr );
 
 // === GLOBALS ===
  int   giNumberOfPings = 1;
@@ -137,127 +136,3 @@ void PrintHelp(char *ProgName)
        fprintf(stderr, " -h\tPrint this message\n");
 }
 
-/**
- * \brief Read an IPv4 Address
- */
-int GetAddress4(char *String, uint8_t *Addr)
-{
-        int    i = 0;
-        int    j;
-        int    val;
-       
-       for( j = 0; String[i] && j < 4; j ++ )
-       {
-               val = 0;
-               for( ; String[i] && String[i] != '.'; i++ )
-               {
-                       if('0' > String[i] || String[i] > '9') {
-                               printf("0<c<9 expected, '%c' found\n", String[i]);
-                               return 0;
-                       }
-                       val = val*10 + String[i] - '0';
-               }
-               if(val > 255) {
-                       printf("val > 255 (%i)\n", val);
-                       return 0;
-               }
-               Addr[j] = val;
-               
-               if(String[i] == '.')
-                       i ++;
-       }
-       if( j != 4 ) {
-               printf("4 parts expected, %i found\n", j);
-               return 0;
-       }
-       if(String[i] != '\0') {
-               printf("EOS != '\\0', '%c'\n", String[i]);
-               return 0;
-       }
-       return 1;
-}
-
-/**
- * \brief Read an IPv6 Address
- */
-int GetAddress6(char *String, uint8_t *Addr)
-{
-        int    i = 0;
-        int    j, k;
-        int    val, split = -1, end;
-       uint16_t        hi[8], low[8];
-       
-       for( j = 0; String[i] && j < 8; j ++ )
-       {
-               if(String[i] == ':') {
-                       if(split != -1) {
-                               printf("Two '::'s\n");
-                               return 0;
-                       }
-                       split = j;
-                       i ++;
-                       continue;
-               }
-               
-               val = 0;
-               for( k = 0; String[i] && String[i] != ':'; i++, k++ )
-               {
-                       val *= 16;
-                       if('0' <= String[i] && String[i] <= '9')
-                               val += String[i] - '0';
-                       else if('A' <= String[i] && String[i] <= 'F')
-                               val += String[i] - 'A' + 10;
-                       else if('a' <= String[i] && String[i] <= 'f')
-                               val += String[i] - 'a' + 10;
-                       else {
-                               printf("%c unexpected\n", String[i]);
-                               return 0;
-                       }
-               }
-               
-               if(val > 0xFFFF) {
-                       printf("val (0x%x) > 0xFFFF\n", val);
-                       return 0;
-               }
-               
-               if(split == -1)
-                       hi[j] = val;
-               else
-                       low[j-split] = val;
-               
-               if( String[i] == ':' ) {
-                       i ++;
-               }
-       }
-       end = j;
-       
-       for( j = 0; j < split; j ++ )
-       {
-               Addr[j*2] = hi[j]>>8;
-               Addr[j*2+1] = hi[j]&0xFF;
-       }
-       for( ; j < 8 - (end - split); j++ )
-       {
-               Addr[j*2] = 0;
-               Addr[j*2+1] = 0;
-       }
-       k = 0;
-       for( ; j < 8; j ++, k++)
-       {
-               Addr[j*2] = hi[k]>>8;
-               Addr[j*2+1] = hi[k]&0xFF;
-       }
-       
-       return 1;
-}
-
-int GetAddress(char *String, uint8_t *Addr)
-{
-       if( GetAddress4(String, Addr) )
-               return 4;
-       
-       if( GetAddress6(String, Addr) )
-               return 6;
-       
-       return 0;
-}
index 57e49be..e32dd60 100644 (file)
@@ -19,7 +19,7 @@ DEPFILES := $(addsuffix .dep,$(OBJ))
 all: $(_BIN) $(_XBIN)
 
 clean:
-       $(RM) $(_BIN) $(_XBIN) $(OBJ) $(_BIN).dsm $(DEPFILES)
+       $(RM) $(_BIN) $(_XBIN) $(OBJ) $(_BIN).dsm $(DEPFILES) $(EXTRACLEAN)
 
 install: all
        @echo [xCP] $(DISTROOT)/Libs/$(BIN)
index 178b75e..585e710 100644 (file)
@@ -8,6 +8,7 @@ OBJ := main.o lib.o loadlib.o export.o elf.o pe.o
 OBJ += arch/$(ARCHDIR).ao
 BIN = ld-acess.so
 EXTRABIN := libld-acess.so
+EXTRACLEAN := $(_OBJPREFIX)_stublib.o
 
 CFLAGS   = -g -Wall -fno-builtin -fno-leading-underscore -fno-stack-protector -fPIC
 CFLAGS  += $(CPPFLAGS)

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