# Building audio/oss weird clang_werror



## Alain De Vos (Mar 18, 2022)

pci_write_config ; osdev->dip

```
[00:01:23] gawk: cmd. line:58: warning: regexp escape sequence `\o' is not a known regexp operator
[00:01:23] gawk: cmd. line:116: warning: regexp escape sequence `\,' is not a known regexp operator
[00:01:23] gawk: cmd. line:116: warning: regexp escape sequence `\;' is not a known regexp operator
[00:01:23] gawk: cmd. line:58: warning: regexp escape sequence `\o' is not a known regexp operator
[00:01:23] gawk: cmd. line:116: warning: regexp escape sequence `\,' is not a known regexp operator
[00:01:23] gawk: cmd. line:116: warning: regexp escape sequence `\;' is not a known regexp operator
[00:01:23] cd prototype/usr/local/lib/oss/build && sh install.sh
[00:01:23] Compiling module osscore
[00:01:24] Compiling osscore module failed
[00:01:24] machine -> /usr/src/sys/amd64/include
[00:01:24] x86 -> /usr/src/sys/x86/include
[00:01:24] awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
[00:01:24] awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
[00:01:24] awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -h
[00:01:24] touch opt_global.h
[00:01:24] Warning: Object directory not changed from original /wrkdirs/usr/ports/audio/oss/work/.build/prototype/usr/local/lib/oss/build
[00:01:24] /usr/local/bin/ccache cc  -O2 -pipe -march=ivybridge -fno-strict-aliasing ""-fno-lto -O2 -pipe -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fstack-protector -fno-short-enums -fexceptions -fident -fverbose-asm -frecord-gcc-switches -fvisibility=default -fomit-frame-pointer -fstrict-aliasing"" -march=ivybridge  -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /wrkdirs/usr/ports/audio/oss/work/.build/prototype/usr/local/lib/oss/build/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include     -MD  -MF.depend.osscore.o -MTosscore.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c osscore.c -o osscore.o
[00:01:24] osscore.c:150:38: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   intr->irqres = bus_alloc_resource (osdev->dip, SYS_RES_IRQ, &(intr->irqid),
[00:01:24]                                      ^~~~~~~~~~
[00:01:24] /usr/src/sys/sys/bus.h:515:46: note: passing argument to parameter 'dev' here
[00:01:24] struct  resource *bus_alloc_resource(device_t dev, int type, int *rid,
[00:01:24]                                               ^
[00:01:24] osscore.c:159:31: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   intr->irq = bus_setup_intr (osdev->dip, intr->irqres,
[00:01:24]                               ^~~~~~~~~~
[00:01:24] /usr/src/sys/sys/bus.h:535:29: note: passing argument to parameter 'dev' here
[00:01:24] int     bus_setup_intr(device_t dev, struct resource *r, int flags,
[00:01:24]                                 ^
[00:01:24] osscore.c:182:21: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]         bus_teardown_intr (osdev->dip, intr->irqres, intr->cookie);
[00:01:24]                            ^~~~~~~~~~
[00:01:24] /usr/src/sys/sys/bus.h:538:32: note: passing argument to parameter 'dev' here
[00:01:24] int     bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
[00:01:24]                                    ^
[00:01:24] osscore.c:183:24: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]         bus_release_resource (osdev->dip, SYS_RES_IRQ, intr->irqid,
[00:01:24]                               ^~~~~~~~~~
[00:01:24] /usr/src/sys/sys/bus.h:532:35: note: passing argument to parameter 'dev' here
[00:01:24] int     bus_release_resource(device_t dev, int type, int rid,
[00:01:24]                                       ^
[00:01:24] osscore.c:201:27: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   *val = pci_read_config (osdev->dip, where, 1);
[00:01:24]                           ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:401:26: note: passing argument to parameter 'dev' here
[00:01:24] pci_read_config(device_t dev, int reg, int width)
[00:01:24]                          ^
[00:01:24] osscore.c:208:27: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   *val = pci_read_config (osdev->dip, where, 1);
[00:01:24]                           ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:401:26: note: passing argument to parameter 'dev' here
[00:01:24] pci_read_config(device_t dev, int reg, int width)
[00:01:24]                          ^
[00:01:24] osscore.c:216:27: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   *val = pci_read_config (osdev->dip, where, 2);
[00:01:24]                           ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:401:26: note: passing argument to parameter 'dev' here
[00:01:24] pci_read_config(device_t dev, int reg, int width)
[00:01:24]                          ^
[00:01:24] osscore.c:224:27: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   *val = pci_read_config (osdev->dip, where, 4);
[00:01:24]                           ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:401:26: note: passing argument to parameter 'dev' here
[00:01:24] pci_read_config(device_t dev, int reg, int width)
[00:01:24]                          ^
[00:01:24] osscore.c:232:21: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   pci_write_config (osdev->dip, where, val, 1);
[00:01:24]                     ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:407:27: note: passing argument to parameter 'dev' here
[00:01:24] pci_write_config(device_t dev, int reg, uint32_t val, int width)
[00:01:24]                           ^
[00:01:24] osscore.c:240:21: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   pci_write_config (osdev->dip, where, val, 2);
[00:01:24]                     ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:407:27: note: passing argument to parameter 'dev' here
[00:01:24] pci_write_config(device_t dev, int reg, uint32_t val, int width)
[00:01:24]                           ^
[00:01:24] osscore.c:248:21: error: incompatible pointer types passing 'dev_info_t *' (aka 'struct device *') to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
[00:01:24]   pci_write_config (osdev->dip, where, val, 4);
[00:01:24]                     ^~~~~~~~~~
[00:01:24] /usr/src/sys/dev/pci/pcivar.h:407:27: note: passing argument to parameter 'dev' here
[00:01:24] pci_write_config(device_t dev, int reg, uint32_t val, int width)
[00:01:24]                           ^
[00:01:24] 11 errors generated.
[00:01:24] *** Error code 1
[00:01:24] 
[00:01:24] Stop.
[00:01:24] make[2]: stopped in /wrkdirs/usr/ports/audio/oss/work/.build/prototype/usr/local/lib/oss/build
[00:01:24] *** Error code 1
[00:01:24] 
[00:01:24] Stop.
[00:01:24] make[1]: stopped in /wrkdirs/usr/ports/audio/oss/work/.build
[00:01:24] *** Error code 1
[00:01:24] 
[00:01:24] Stop.
[00:01:24] make: stopped in /usr/ports/audio/oss
[00:01:33] =>> Cleaning up wrkdir
[00:01:33] ===>  Cleaning for oss-4.2.b2019_2
[00:01:37] build of audio/oss | oss-4.2.b2019_2 ended at Sat Mar 19 00:22:54 CET 2022
[00:01:37] build time: 00:01:37
[00:01:37] !!! build failure encountered !!!
```


----------



## Alain De Vos (Mar 19, 2022)

According to my humble opinion the OSS port does not work correctly with a make.conf with different .if .then parts.
This or i have a syntax error in my make.conf , and make does not really care about syntax .
Or there is a problem with the use of python3.9


----------



## zirias@ (Mar 19, 2022)

On a quick glance, looks like in-kernel API changes. Did you check it actually builds fine on the official builders?

As FreeBSD's own dsp devices are compatible with OSS, do you really need this software?


----------



## Alain De Vos (Mar 19, 2022)

I wanted to avoid PULSEAUDIO so i started using OSS.
I have only one port really dependend on it : qmmp-qt5-1.5.2.


----------



## zirias@ (Mar 19, 2022)

Alain De Vos said:


> I wanted to avoid PULSEAUDIO so i started using OSS.


Well, as I said, FreeBSD's dsp devices implement OSS, so normally, there's no need for additional software ...



Alain De Vos said:


> I have only one port really dependend on it : qmmp-qt5-1.5.2.


Uh, this one has strange option defaults:

```
OSS=off: Open Sound System support
     OSS4=on: Open Sound System (ver4) support
```

I wonder whether there's any sane reason for it. Instead of installing additional software, I'd first try to disable `OSS4` and enable `OSS` instead.


----------



## grahamperrin@ (Mar 20, 2022)

Which version of FreeBSD, exactly?


----------



## Alain De Vos (Mar 20, 2022)

13.1-BETA2


----------



## PMc (Jul 14, 2022)

Same crappy problem here.

I have an ALC887 soundchip and this is beautiful: all the plugs are shown with their proper colors and are configurable and have little faders attached, no need to work with nids and mixer.
Now I'm using a board with VIA chip, and this is only understood as default HDA, no individual colors etc. So preference may depend on the actual soundchip.
But then, recently, when somebody upgraded the jack port to jack-2, they botched it, and it does no longer work properly. 
Nevertheless I keep it to compile, as maybe I switch back to the other board, or maybe I don't use jack anymore, or maybe I find a way to fix or workaround it.


----------



## PMc (Jul 15, 2022)

Patch the patch:

```
index 434fbd538dca..a613fbe2648c 100644
--- a/audio/oss/files/patch-kernel_OS_FreeBSD_wrapper_bsddefs.h
+++ b/audio/oss/files/patch-kernel_OS_FreeBSD_wrapper_bsddefs.h
@@ -4,7 +4,7 @@
  #endif
  extern int oss_get_uid (void);
  
-+#if __FreeBSD_version > 1400009
++#if __FreeBSD_version >= 1301000
 +typedef struct _device dev_info_t;
 +#else
  typedef struct device dev_info_t;
```


This should solve it. But, as I'm not currently using it, I don't know if it will work - only that it compiles now.

Wasn't easy to find. The "incompatible pointer type" is the root cause. 

Normally, with such an error, we look at what is pointed at - and if that is the same, it is just a rename, and we can adjust accordingly. And normally we can search for the name with something like `find /usr/include /usr/src/sys/sys -name "*.h" | xargs grep name`, and we should get (a lot of references and) somewhere the original definition of the thing (or a definition that references another name, etc.etc. and finally the original definition).

But not in this case. The original definition isn't present, only the pointer is used. And the name has changed, that is obvious when looking at device (9) for 12.3 and 13.1.
I finally found the original definition, not in a header file, but in subr_bus.c (not sure if it appears elsewhere also). It seems that definition is intended be kept internal to whatever bus maintenance stuff (it is also a good way to make sure nobody understands the code).

Anyway, the structure definition itself is not different betwenn 12.3 and 13.1. So it is just a matter of adjusting the name in the audio/oss. And then I found, this had already been done, but for Rel.14, not for 13.


----------



## crees@ (Sep 11, 2022)

Fantastic, thanks for this- I've had a PR pointing to this.  I'll get it in.


----------

