dereferencing pointer to incomplete type?!

odenter

Well-Known Member
Hi,

ich habe hier ein Buch liegen und probieren gerade den Code aus.

Code:
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>


/* Systemcall Arguments */
struct sc_axample_args
{
  char *str;
};

static int sc(struct thread *td, void *syscall_args)
{
  struct sc_example_args *uap;
  uap = (struct sc_axample_args*)syscall_args;
  printf("%s\n", uap->str);
  
  return 0;
}

/* sysent for new systemcall  */
static struct sysent sc_example_sysent = {
  1,
  sc
};

/* offset in sysent[] where the system call is to be allocated  */
static int offset = NO_SYSCALL;

/* function called at load/unload  */
static int load(struct module *module, int cmd, void *arg)
{
  int error = 0;
  
  switch(cmd) 
  {
    case MOD_LOAD:
    {
      uprintf("System call loaded at offset %d.\n", offset);
      break;
    }
    
    case MOD_UNLOAD:
    {
      uprintf("System call unloaded from offset %d.\n", offset);
      break;
    }
    
    default:
    {
      error = EOPNOTSUPP;
      break;
    }
  } // end switch
  
  return error;
}

SYSCALL_MODULE(sc, &offset, &sc_example_sysent, load, NULL);

Fehlermeldung:
Code:
%make
Warning: Object directory not changed from original /usr/home/odenter/dev/sc
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
cc -O2 -fno-strict-aliasing -pipe -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I-   -I. -I@ -I@/contrib/altq -I@/../include -I/usr/include -finline-limit=8000 -fno-common  -mno-align-long-strings -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -ffreestanding -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions -std=c99 -c sc.c
sc.c: In function `sc':
sc.c:19: warning: assignment from incompatible pointer type
sc.c:20: error: dereferencing pointer to incomplete type
*** Error code 1

makefile
Code:
KMOD=	hello
SRCS=	sc.c

.include <bsd.kmod.mk>

Ich verstehe nicht so ganz was der Compiler von mir will.

EDIT:
Ihm gefällt das
Code:
printf("%s\n", uap->str);
nicht so richtig.
 
Zuletzt bearbeitet:
Zurück
Oben