sysprogs / kgdboe

A network interface for GDB for Linux Kernel
60 stars 25 forks source link

Compiler Warnings #20

Open luyaohan1001 opened 1 month ago

luyaohan1001 commented 1 month ago

Getting following compiler warnings. Should I clean this up?

/home/lhan/Projects/kgdboe/kgdboe_main.c:71:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   71 |  int err = kgdboe_io_init(device_name, udp_port, local_ip, force_single_core != 0);
      |  ^~~
  CC [M]  /home/lhan/Projects/kgdboe/kgdboe_io.o
/home/lhan/Projects/kgdboe/kgdboe_io.c: In function ‘kgdboe_read_char’:
/home/lhan/Projects/kgdboe/kgdboe_io.c:88:5: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
   88 |     while (s_IncomingRingBufferReadPosition == s_IncomingRingBufferWritePosition)
      |     ^~~~~
/home/lhan/Projects/kgdboe/kgdboe_io.c:91:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
   91 |  result = s_IncomingRingBuffer[s_IncomingRingBufferReadPosition++];
      |  ^~~~~~
/home/lhan/Projects/kgdboe/kgdboe_io.c: In function ‘force_single_cpu_mode’:
/home/lhan/Projects/kgdboe/kgdboe_io.c:128:9: warning: unused variable ‘cpu’ [-Wunused-variable]
  128 |     int cpu;
      |         ^~~
In file included from /home/lhan/Projects/kgdboe/kgdboe_io.c:8:
/home/lhan/Projects/kgdboe/kgdboe_io.c: In function ‘kgdboe_io_init’:
/home/lhan/Projects/kgdboe/tracewrapper.h:8:30: warning: initialization of ‘int *’ from ‘long unsigned int’ makes pointer from integer without a cast [-Wint-conversion]
    8 | #define kallsyms_lookup_name ((unsigned long(*)(const char *))kallsyms_lookup_name_address)
      |                              ^
/home/lhan/Projects/kgdboe/kgdboe_io.c:175:30: note: in expansion of macro ‘kallsyms_lookup_name’
  175 |     int *_gro_normal_batch = kallsyms_lookup_name("gro_normal_batch");
      |                              ^~~~~~~~~~~~~~~~~~~~
/home/lhan/Projects/kgdboe/kgdboe_io.c:175:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  175 |     int *_gro_normal_batch = kallsyms_lookup_name("gro_normal_batch");
      |     ^~~
In file included from /home/lhan/Projects/kgdboe/kgdboe_io.c:8:
At top level:
/home/lhan/Projects/kgdboe/tracewrapper.h:23:27: warning: ‘do_lookup_tracepoint’ defined but not used [-Wunused-function]
   23 | static struct tracepoint *do_lookup_tracepoint(const char *tracepointName, const char *tracepointPtrName)
      |                           ^~~~~~~~~~~~~~~~~~~~
  CC [M]  /home/lhan/Projects/kgdboe/nethook.o
In file included from /home/lhan/Projects/kgdboe/nethook.c:13:
/home/lhan/Projects/kgdboe/tracewrapper.h:23:27: warning: ‘do_lookup_tracepoint’ defined but not used [-Wunused-function]
   23 | static struct tracepoint *do_lookup_tracepoint(const char *tracepointName, const char *tracepointPtrName)
      |                           ^~~~~~~~~~~~~~~~~~~~
KatCote commented 3 weeks ago

No, all working with this Makefile (Stable 5.19.0):

KERNEL_MODULE_NAME := kgdboe
KERNEL_MODULE_OBJECT_FILE_LIST := irqsync.o kgdboe_main.o kgdboe_io.o nethook.o netpoll_wrapper.o poll_copy.o spinhook.o timerhook.o

obj-m := $(KERNEL_MODULE_NAME).o
$(KERNEL_MODULE_NAME)-y += $(KERNEL_MODULE_OBJECT_FILE_LIST)
ccflags-y := -ggdb -Og -std=gnu99 -Wno-error=unused-function -Wno-error=misleading-indentation -Wno-error=int-conversion -Wno-error=declaration-after-statement