[Lost] [Patch] Compilerwarnungen

Kevin Wolf ·

Antoine Kaufmann schrieb:
> Dieser Patch räumt mal wieder ein bisschen auf und behebt Compilerwarnungen.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: src/kernel/src/init.c
> ===================================================================
> --- src/kernel/src/init.c	(Revision 675)
> +++ src/kernel/src/init.c	(Arbeitskopie)
> @@ -56,6 +56,7 @@
>  #include "io.h"
>  #include "timer.h"
>  #include "shm.h"
> +#include "vm86.h"
>  
>  struct multiboot_info multiboot_info;
>  
> Index: src/kernel/src/syscall.c
> ===================================================================
> --- src/kernel/src/syscall.c	(Revision 675)
> +++ src/kernel/src/syscall.c	(Arbeitskopie)
> @@ -283,7 +283,7 @@
>          {
>              vaddr_t address = *((vaddr_t*) isf->esp);
>              if (is_userspace(address, 1)) {
> -                isf->eax = resolve_vaddr(current_task->cr3, address);
> +                isf->eax = (dword) resolve_vaddr(current_task->cr3, address);
>              } else {
>                  isf->eax = 0;
>              }
> @@ -434,7 +434,6 @@
>              // Das PD-des neuen tasks mappen
>              page_directory_t new_task_pd = new_task->cr3;
>              
> -            dword written = 0;
>              // Speicher wird kopiert, nicht gemappt.
>              while(num--) {
>                  if (!resolve_vaddr(new_task_pd, dest)) {
> @@ -752,7 +751,7 @@
>          case SYSCALL_DEBUG_STACKTRACE:
>          {
>              pid_t pid = *((dword*) (isf->esp));
> -            struct task* task = get_task(*((dword*) (isf->esp)));
> +            struct task* task = get_task(pid);
>  
>              // FIXME: Was bei einem Fehler
>              if (task != NULL) {
> Index: src/kernel/src/vm86.c
> ===================================================================
> --- src/kernel/src/vm86.c	(Revision 675)
> +++ src/kernel/src/vm86.c	(Arbeitskopie)
> @@ -294,7 +297,7 @@
>                  }
>                  // Register speichern
>                  dword *phys_regs = resolve_vaddr(task->parent_task->cr3, (dword*)((dword)info->regs & ~0xFFF));
> -                dword regs = find_contiguous_kernel_pages(1);
> +                dword regs = (dword) find_contiguous_kernel_pages(1);
>                  map_page(kernel_page_directory, (dword*)regs, phys_regs, PTE_P | PTE_W);

Das hier klingt mir sowieso eher nach einem Fall für map_phys_addr()

>                  vm86_regs_t * vm86_regs = (vm86_regs_t *)(regs + ((dword)info->regs & 0xFFF));
>                  vm86_regs->ax = isf->eax;
> @@ -321,7 +324,7 @@
>                  }
>                  // Task beenden
>                  if (!unblock_task(task->parent_task, task->pid)) {
> -                    puts("VM86: Konnte aufrufenden Task nicht wecken!\n");
> +                    kprintf("VM86: Konnte aufrufenden Task nicht wecken!\n");

Ich würde hier eher einen panic ansetzen. Einfach so ein kprintf machen 
wir eigentlich sonst auch nirgends, oder?

> Index: src/include/strings.h
> ===================================================================
> --- src/include/strings.h	(Revision 675)
> +++ src/include/strings.h	(Arbeitskopie)
> @@ -37,9 +37,11 @@
>  #define _STRINGS_H_
>  
>  #include <types.h>
> +#include <string.h>
>  
> +/*
>  int strcasecmp(const char* s1, const char* s2);
> -int strncasecmp(const char* s1, const char* s2, size_t n);
> +int strncasecmp(const char* s1, const char* s2, size_t n);*/

Wieso sollen die auskommentiert werden? Laut man strings.h gehören die 
dort rein.

>  
>  #endif // ifndef _STRINGS_H_
>  
> Index: src/include/string.h
> ===================================================================
> --- src/include/string.h	(Revision 675)
> +++ src/include/string.h	(Arbeitskopie)
> @@ -18,9 +18,9 @@
>  int strcmp(const char* s1, const char* s2);
>  int strncmp(const char* s1, const char* s2, size_t n);
>  
> -/* => strings.h
> +/* => strings.h*/
>  int strcasecmp(const char *s1, const char *s2);
> -int strncasecmp(const char *s1, const char *s2, size_t n);*/
> +int strncasecmp(const char *s1, const char *s2, size_t n);

Und dafür sollte man hier den Kommentar voll ganz löschen.

> Index: src/modules/kbc/keyboard.c
> ===================================================================
> --- src/modules/kbc/keyboard.c	(Revision 675)
> +++ src/modules/kbc/keyboard.c	(Arbeitskopie)
> @@ -23,7 +23,7 @@
>      {27,             27},         // 0x01
>      {'1',           '|'},         // 0x02
>      {'2',           '"'},         // 0x03 F5
> -    {'3',           '§'},         // 0x04 F3
> +    {'3',             0},         // 0x04 F3

Hm? Was war jetzt daran falsch?

> Index: src/modules/cdi/lib/cdi.c
> ===================================================================
> --- src/modules/cdi/lib/cdi.c	(Revision 675)
> +++ src/modules/cdi/lib/cdi.c	(Arbeitskopie)
> @@ -23,6 +23,9 @@
>  
>  static void cdi_destroy(void);
>  
> +// FIXME
> +int atexit(void (*function)(void));
> +

Der korrekte Fix ist folgender:

Index: include/stdlib.h
===================================================================
--- include/stdlib.h    (Revision 685)
+++ include/stdlib.h    (Arbeitskopie)
@@ -61,4 +61,6 @@

  char* mktemp(char* template);

+int atexit(void (*function)(void));
+
  #endif

> Index: src/modules/lib/stdlibc/jprintf.c
> ===================================================================
> --- src/modules/lib/stdlibc/jprintf.c	(Revision 675)
> +++ src/modules/lib/stdlibc/jprintf.c	(Arbeitskopie)
> @@ -55,8 +55,9 @@
>   */
>  unsigned long long divmod(unsigned long long dividend, unsigned int divisor, unsigned int * remainder)
>  {
> -    unsigned int highword = dividend >> 32;
> -    unsigned int lowword = dividend & 0xffffffff;
> +    /*unsigned int highword = dividend >> 32;
> +    unsigned int lowword = dividend & 0xffffffff;
> +*/

Wenn die Variablen unnötig sind, bitte löschen, nicht nur auskommentieren.

> Index: src/modules/lib/gui/gui.c
> ===================================================================
> --- src/modules/lib/gui/gui.c	(Revision 675)
> +++ src/modules/lib/gui/gui.c	(Arbeitskopie)
> @@ -284,12 +285,12 @@
>  
>  int render_char(bitmap_t bitmap, font_t *font, unsigned char c, int x, int y)
>  {
> -    int glyph_index = ((int*)font->data)[c];
> +    //int glyph_index = ((int*)font->data)[c];
>      //printf("Index: %d\n", glyph_index);
>      int offset = ((int*)font->data)[257 + c];
>      //printf("Offset: %d\n", offset);
>      int *glyph_data = (int*)(((char*)font->data) + offset);
> -    int width = glyph_data[0];
> +    //int width = glyph_data[0];

Hier nochmal zwei davon.

> Index: src/modules/lib/envvars.c
> ===================================================================
> --- src/modules/lib/envvars.c	(Revision 675)
> +++ src/modules/lib/envvars.c	(Arbeitskopie)
> @@ -37,6 +37,7 @@
>  #include "syscall.h"
>  #include "stdlib.h"
>  #include "string.h"
> +#include <stdio.h>

io.h ist es, die man braucht (der Fix ist doch für io_get_absolute_path, 
oder?)

> Index: src/modules/lib/video/bitmap.c
> ===================================================================
> --- src/modules/lib/video/bitmap.c	(Revision 675)
> +++ src/modules/lib/video/bitmap.c	(Arbeitskopie)
> @@ -475,7 +475,8 @@
>          height = bitmap.height - y - offsety;
>      }
>      //Bitmap zeichnen
> -    int ix, iy;
> +    int iy;
> +    // int ix

wtf? Bis jetzt dachte ich, du machst das Auskommentieren aus 
Bequemlichkeit, aber das kann es hier ja nicht gewesen sein... ;-)

Antworten