git: adc6bf772068 - main - x11/nvidia-driver (legacy versions): unbreak the build on fresh -CURRENT

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Thu, 28 Apr 2022 11:24:40 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=adc6bf772068a1adc8aec74074988ebab048d769

commit adc6bf772068a1adc8aec74074988ebab048d769
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-04-28 11:23:46 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-04-28 11:23:46 +0000

    x11/nvidia-driver (legacy versions): unbreak the build on fresh -CURRENT
    
    Recently, FreeBSD had started to enforce -Werror,-Wunused-but-set-variable
    for kernel code, which affects 3rd-party modules such as nVidia drivers.
    Newer versions of the driver are ready for that, but legacy one were not.
    
    Reported by:    pkg-fallout
    PR:             263418
---
 x11/nvidia-driver/Makefile                         |  5 +++++
 .../files/extra-patch-src-nvidia_ctl.c.in          | 23 ++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/x11/nvidia-driver/Makefile b/x11/nvidia-driver/Makefile
index 790cb87bed84..4962687b0e93 100644
--- a/x11/nvidia-driver/Makefile
+++ b/x11/nvidia-driver/Makefile
@@ -226,6 +226,11 @@ post-patch: .SILENT
 	gsed ${REINPLACE_ARGS} -E "s,/etc/egl/egl_external_platform\.d.{$$padding},${EGL_JSON_PATH}\x00," \
 		${WRKSRC}/obj/libEGL_nvidia.so.0
 .endif
+# Unbreak the build against -Werror,-Wunused-but-set-variable CFLAGS
+.if ${NVVERSION} < 450.51
+	${REINPLACE_CMD} -e '/void nvidia_dev_dtor/,+8s,.*status.*,,' \
+		${WRKSRC}/src/${NVSRC}/nvidia_dev.c
+.endif
 # Finally, process OPTIONS
 .if ${PORT_OPTIONS:MFREEBSD_AGP}
 	${REINPLACE_CMD} -E 's/undef (NV_SUPPORT_OS_AGP)/define \1/' \
diff --git a/x11/nvidia-driver/files/extra-patch-src-nvidia_ctl.c.in b/x11/nvidia-driver/files/extra-patch-src-nvidia_ctl.c.in
index a187792bd1cd..83d57711b948 100644
--- a/x11/nvidia-driver/files/extra-patch-src-nvidia_ctl.c.in
+++ b/x11/nvidia-driver/files/extra-patch-src-nvidia_ctl.c.in
@@ -13,6 +13,21 @@
  static d_open_t  nvidia_ctl_open;
  static void nvidia_ctl_dtor(void *arg);
  static d_ioctl_t nvidia_ctl_ioctl;
+@@ -65,13 +71,12 @@ static int nvidia_ctl_open(
+ 
+ void nvidia_ctl_dtor(void *arg)
+ {
+-    int status;
+     struct nvidia_filep *filep = arg;
+     struct nvidia_event *et;
+     nv_state_t *nv = filep->nv;
+ 
+     nv_lock_api(nv);
+-    status = nvidia_close_ctl(nv, filep);
++    nvidia_close_ctl(nv, filep);
+     nv_unlock_api(nv);
+ 
+     while ((et = STAILQ_FIRST(&filep->event_queue))) {
 @@ -138,6 +144,18 @@ static int nvidia_ctl_poll(
  
  int nvidia_ctl_attach(void)
@@ -43,10 +58,13 @@
      }
  
      nvidia_count++;
-@@ -153,13 +175,28 @@ int nvidia_ctl_attach(void)
+@@ -153,13 +175,25 @@ int nvidia_ctl_attach(void)
  
  int nvidia_ctl_detach(void)
  {
+-    struct nvidia_softc *sc;
+-
+-    sc = &nvidia_ctl_sc;
 +#ifdef NV_SUPPORT_LINUX_COMPAT
 +    struct linux_device_handler nvidia_ctl_linux_handler = {
 +        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
@@ -58,9 +76,6 @@
 +        .linux_char_device = 1
 +    };
 +#endif
-     struct nvidia_softc *sc;
- 
-     sc = &nvidia_ctl_sc;
      nvidia_count--;
  
 -    if (nvidia_count == 0)