Anthony96922 / mt7601u-ap

AP driver for MT7601U dongles
GNU General Public License v2.0
117 stars 49 forks source link

Compilation error (mcu/rtmp_mcu.c:42:1: error: control reaches end of non-void function) #31

Closed ppar closed 2 years ago

ppar commented 3 years ago

TL;DR

Long version:

Removing the offending -W... option from the global Makefile works around the problem and the module compiles successfully. Looking at mcu/rtmp_mcu.c it doesn't look like the functions aren't supposed to return anything, but I didn't dig any deeper.

Environment:

Installed kernel:

$ uname -a
Linux raspberrypi 5.10.52-v7+ #1441 SMP Tue Aug 3 18:10:09 BST 2021 armv7l GNU/Linux
Package: raspberrypi-kernel
Source: raspberrypi-firmware
Version: 1:1.20210805-1
Architecture: armhf
Maintainer: Serge Schneider <serge@raspberrypi.org>
Homepage: https://github.com/raspberrypi/firmware
Package: raspberrypi-kernel-headers
Source: raspberrypi-firmware
Version: 1:1.20210805-1
Architecture: armhf
Maintainer: Serge Schneider <serge@raspberrypi.org>
Provides: linux-headers
Homepage: https://github.com/raspberrypi/firmware

Hardware:

Hardware        : BCM2835
Revision        : a21041
Model           : Raspberry Pi 2 Model B Rev 1.1

Compiled against revision:

pfp@raspberrypi:~/mt7601u-ap $ git log | head
commit 624307427149e53b75937ccbe7cb235ec3ef2f58
Merge: b91889b df2d53e
Author: Anthony96922 <anthony96922@gmail.com>
Date:   Thu Apr 30 17:29:21 2020 -0700

    Merge pull request #19 from z59/linux-5.6

Error from make:

[...]
  CC [M]  /home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.o
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c: In function âMCUBurstWriteâ:
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:33:38: warning: passing argument 3 of âRTUSBMultiWrite_nBytesâ from incompatible pointer type [-Wincompatible-pointer-types]
  RTUSBMultiWrite_nBytes(pAd, Offset, Data, Cnt * 4, 64);
                                      ^~~~
In file included from /home/pfp/mt7601u-ap/include/rt_config.h:62,
                 from /home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:29:
/home/pfp/mt7601u-ap/include/rtmp.h:8258:41: note: expected âPUCHARâ {aka âunsigned char *â} but argument is of type âUINT32 *â {aka âunsigned int *â}
         IN      PUCHAR                  pData,
                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c: In function âChipOpsMCUHookâ:
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:65:25: warning: assignment to âVOID (*)(struct _RTMP_ADAPTER *, UINT32,  UINT32)â {aka âvoid (*)(struct _RTMP_ADAPTER *, unsigned int,  unsigned int)â} from incompatible pointer type âINT (*)(struct _RTMP_ADAPTER *, UINT32,  UINT32)â {aka âint (*)(struct _RTMP_ADAPTER *, unsigned int,  unsigned int)â} [-Wincompatible-pointer-types]
   pChipOps->Calibration = AndesCalibrationOP;
                         ^
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:72:25: warning: assignment to âINT (*)(struct _RTMP_ADAPTER *, RTMP_REG_PAIR *, UINT32)â {aka âint (*)(struct _RTMP_ADAPTER *, struct _RTMP_REG_PAIR *, unsigned int)â} from incompatible pointer type âINT (*)(struct _RTMP_ADAPTER *, UINT32,  ...)â {aka âint (*)(struct _RTMP_ADAPTER *, unsigned int,  ...)â} [-Wincompatible-pointer-types]
   pChipOps->RandomWrite = AndesRandomWrite;
                         ^
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:73:27: warning: assignment to âINT (*)(struct _RTMP_ADAPTER *, BANK_RF_REG_PAIR *, UINT32)â {aka âint (*)(struct _RTMP_ADAPTER *, struct _BANK_RF_REG_PAIR *, unsigned int)â} from incompatible pointer type âINT (*)(struct _RTMP_ADAPTER *, UINT32,  ...)â {aka âint (*)(struct _RTMP_ADAPTER *, unsigned int,  ...)â} [-Wincompatible-pointer-types]
   pChipOps->RFRandomWrite = AndesRFRandomWrite;
                           ^
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c: In function âMCUBurstWriteâ:
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:34:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c: In function âMCURandomWriteâ:
/home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.c:42:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:280: /home/pfp/mt7601u-ap/os/linux/../../mcu/rtmp_mcu.o] Error 1
make[1]: *** [Makefile:1824: /home/pfp/mt7601u-ap/os/linux] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.10.52-v7+'
make: *** [Makefile:73: LINUX] Error 2

Applied hack:

pfp@raspberrypi:~/mt7601u-ap $ sudo sed -i.bak 's/-Werror=return-type//' /usr/src/linux-headers-$(uname -r)/Makefile
pfp@raspberrypi:~/mt7601u-ap $ diff -u /usr/src/linux-headers-$(uname -r)/Makefile{.bak,}
--- /usr/src/linux-headers-5.10.52-v7+/Makefile.bak     2021-07-27 22:16:17.000000000 +0000
+++ /usr/src/linux-headers-5.10.52-v7+/Makefile 2021-08-23 00:53:17.422933885 +0000
@@ -496,7 +496,7 @@
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
                   -Werror=implicit-function-declaration -Werror=implicit-int \
-                  -Werror=return-type -Wno-format-security \
+                   -Wno-format-security \
                   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
simon0356 commented 3 years ago

Hi, I observe same issue and get to the same conclusion, It seem "-Werror=return-type" appear at 4.19.0-14-amd64, i have successfully build the module on a 4.19.0-13-amd64

Anthony96922 commented 2 years ago

I have fixed the error in commit 8f7a213c14f5b074e5432e33c082f99487b3e97d.