On Thu, Dec 22, 2022 at 01:14:57AM +0100, Patrick Wildt wrote: > On Tue, Dec 20, 2022 at 05:48:41PM -0700, Todd C. Miller wrote: > > On Tue, 20 Dec 2022 23:44:08 +0100, Patrick Wildt wrote: > > > > > clang complains when the function is declared with a fixed array size in > > > a parameter while the prototype is unbounded, like this: > > > > > > /usr/src/sys/net/pf.c:4353:54: error: argument 'sns' of type 'struct > > > pf_src_n > > > ode *[4]' with mismatched bound [-Werror,-Warray-parameter] > > > struct pf_rule_actions *act, struct pf_src_node *sns[PF_SN_MAX]) > > > ^ > > > /usr/src/sys/net/pf.c:203:28: note: previously declared as 'struct > > > pf_src_nod > > > e *[]' here > > > struct pf_src_node *[]); > > > ^ > > > 1 error generated. > > > > > > We have a few of that, and was wondering what the better solution is. > > > clang apparently accepts using * instead of []. The alternative would > > > be to hardcode the size in the prototype as well. Here's a diff for > > > a three files for the first version, as example. > > > > Using * instead of [] is the saner approach. Hard-coding the sizes > > into the prototype seems like a bad idea, even if clang is now smart > > enough to complain about a mismatch. > > > > - todd > > So, here's the full diff that allows me to compile arm64 GENERIC.MP, > with radeondrm and amdgpu disabled.
Right, sorry for derailing the thread with a different discussion. Here's a diff only for the array/ptr changes. ok? Patrick diff --git a/sys/crypto/sha2.c b/sys/crypto/sha2.c index f789ef3f55b..b2b79f286f3 100644 --- a/sys/crypto/sha2.c +++ b/sys/crypto/sha2.c @@ -470,7 +470,7 @@ SHA256Update(SHA2_CTX *context, const void *dataptr, size_t len) } void -SHA256Final(u_int8_t digest[], SHA2_CTX *context) +SHA256Final(u_int8_t *digest, SHA2_CTX *context) { unsigned int usedspace; @@ -795,7 +795,7 @@ SHA512Last(SHA2_CTX *context) } void -SHA512Final(u_int8_t digest[], SHA2_CTX *context) +SHA512Final(u_int8_t *digest, SHA2_CTX *context) { SHA512Last(context); @@ -834,7 +834,7 @@ SHA384Update(SHA2_CTX *context, const void *data, size_t len) } void -SHA384Final(u_int8_t digest[], SHA2_CTX *context) +SHA384Final(u_int8_t *digest, SHA2_CTX *context) { SHA512Last(context); diff --git a/sys/dev/ic/ar5008.c b/sys/dev/ic/ar5008.c index cad0f142210..4c0126fd6d6 100644 --- a/sys/dev/ic/ar5008.c +++ b/sys/dev/ic/ar5008.c @@ -111,7 +111,7 @@ void ar5008_next_calib(struct athn_softc *); void ar5008_calib_iq(struct athn_softc *); void ar5008_calib_adc_gain(struct athn_softc *); void ar5008_calib_adc_dc_off(struct athn_softc *); -void ar5008_write_txpower(struct athn_softc *, int16_t power[]); +void ar5008_write_txpower(struct athn_softc *, int16_t *); void ar5008_set_viterbi_mask(struct athn_softc *, int); void ar5008_hw_init(struct athn_softc *, struct ieee80211_channel *, struct ieee80211_channel *); @@ -119,9 +119,9 @@ uint8_t ar5008_get_vpd(uint8_t, const uint8_t *, const uint8_t *, int); void ar5008_get_pdadcs(struct athn_softc *, uint8_t, struct athn_pier *, struct athn_pier *, int, int, uint8_t, uint8_t *, uint8_t *); void ar5008_get_lg_tpow(struct athn_softc *, struct ieee80211_channel *, - uint8_t, const struct ar_cal_target_power_leg *, int, uint8_t[]); + uint8_t, const struct ar_cal_target_power_leg *, int, uint8_t *); void ar5008_get_ht_tpow(struct athn_softc *, struct ieee80211_channel *, - uint8_t, const struct ar_cal_target_power_ht *, int, uint8_t[]); + uint8_t, const struct ar_cal_target_power_ht *, int, uint8_t *); void ar5008_set_noise_immunity_level(struct athn_softc *, int); void ar5008_enable_ofdm_weak_signal(struct athn_softc *); void ar5008_disable_ofdm_weak_signal(struct athn_softc *); diff --git a/sys/dev/ic/ar9003.c b/sys/dev/ic/ar9003.c index 565ea27c701..7ec3131f86b 100644 --- a/sys/dev/ic/ar9003.c +++ b/sys/dev/ic/ar9003.c @@ -114,7 +114,7 @@ int ar9003_init_calib(struct athn_softc *); void ar9003_do_calib(struct athn_softc *); void ar9003_next_calib(struct athn_softc *); void ar9003_calib_iq(struct athn_softc *); -int ar9003_get_iq_corr(struct athn_softc *, int32_t[], int32_t[]); +int ar9003_get_iq_corr(struct athn_softc *, int32_t *, int32_t *); int ar9003_calib_tx_iq(struct athn_softc *); void ar9003_paprd_calib(struct athn_softc *, struct ieee80211_channel *); int ar9003_get_desired_txgain(struct athn_softc *, int, int); @@ -126,17 +126,17 @@ int ar9003_compute_predistortion(struct athn_softc *, const uint32_t *, void ar9003_enable_predistorter(struct athn_softc *, int); void ar9003_paprd_enable(struct athn_softc *); void ar9003_paprd_tx_tone_done(struct athn_softc *); -void ar9003_write_txpower(struct athn_softc *, int16_t power[]); +void ar9003_write_txpower(struct athn_softc *, int16_t *); void ar9003_reset_rx_gain(struct athn_softc *, struct ieee80211_channel *); void ar9003_reset_tx_gain(struct athn_softc *, struct ieee80211_channel *); void ar9003_hw_init(struct athn_softc *, struct ieee80211_channel *, struct ieee80211_channel *); void ar9003_get_lg_tpow(struct athn_softc *, struct ieee80211_channel *, uint8_t, const uint8_t *, const struct ar_cal_target_power_leg *, - int, uint8_t[]); + int, uint8_t *); void ar9003_get_ht_tpow(struct athn_softc *, struct ieee80211_channel *, uint8_t, const uint8_t *, const struct ar_cal_target_power_ht *, - int, uint8_t[]); + int, uint8_t *); void ar9003_set_noise_immunity_level(struct athn_softc *, int); void ar9003_enable_ofdm_weak_signal(struct athn_softc *); void ar9003_disable_ofdm_weak_signal(struct athn_softc *); diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c index 2d7551eaef3..d7f25d59919 100644 --- a/sys/dev/ic/rtwn.c +++ b/sys/dev/ic/rtwn.c @@ -151,19 +151,19 @@ void rtwn_pa_bias_init(struct rtwn_softc *); void rtwn_rxfilter_init(struct rtwn_softc *); void rtwn_edca_init(struct rtwn_softc *); void rtwn_rate_fallback_init(struct rtwn_softc *); -void rtwn_write_txpower(struct rtwn_softc *, int, uint16_t[]); +void rtwn_write_txpower(struct rtwn_softc *, int, uint16_t *); void rtwn_get_txpower(struct rtwn_softc *sc, int, struct ieee80211_channel *, struct ieee80211_channel *, - uint16_t[]); + uint16_t *); void rtwn_r92c_get_txpower(struct rtwn_softc *, int, struct ieee80211_channel *, struct ieee80211_channel *, - uint16_t[]); + uint16_t *); void rtwn_r92e_get_txpower(struct rtwn_softc *, int, struct ieee80211_channel *, - struct ieee80211_channel *, uint16_t[]); + struct ieee80211_channel *, uint16_t *); void rtwn_r88e_get_txpower(struct rtwn_softc *, int, struct ieee80211_channel *, - struct ieee80211_channel *, uint16_t[]); + struct ieee80211_channel *, uint16_t *); void rtwn_set_txpower(struct rtwn_softc *, struct ieee80211_channel *, struct ieee80211_channel *); void rtwn_set_chan(struct rtwn_softc *, diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index c8bba8d51a4..5da27021ecf 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -74,8 +74,8 @@ int kqpoll_debug = 0; printf(x); \ } -int pselregister(struct proc *, fd_set *[], fd_set *[], int, int *, int *); -int pselcollect(struct proc *, struct kevent *, fd_set *[], int *); +int pselregister(struct proc *, fd_set **, fd_set **, int, int *, int *); +int pselcollect(struct proc *, struct kevent *, fd_set **, int *); void ppollregister(struct proc *, struct pollfd *, int, int *, int *); int ppollcollect(struct proc *, struct kevent *, struct pollfd *, u_int); diff --git a/sys/net/pf.c b/sys/net/pf.c index 1ee69b734e7..8439f5d19f3 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -201,7 +201,7 @@ static __inline int pf_create_state(struct pf_pdesc *, struct pf_rule *, struct pf_state_key **, struct pf_state_key **, int *, struct pf_state **, int, struct pf_rule_slist *, struct pf_rule_actions *, - struct pf_src_node *[]); + struct pf_src_node **); static __inline int pf_state_key_addr_setup(struct pf_pdesc *, void *, int, struct pf_addr *, int, struct pf_addr *, int, int); diff --git a/sys/net/toeplitz.h b/sys/net/toeplitz.h index 3ce66ead3ba..810b93ffd88 100644 --- a/sys/net/toeplitz.h +++ b/sys/net/toeplitz.h @@ -54,7 +54,7 @@ uint16_t stoeplitz_hash_ip6port(const struct stoeplitz_cache *, #endif uint16_t stoeplitz_hash_eaddr(const struct stoeplitz_cache *, - const uint8_t []); + const uint8_t *); /* hash a uint16_t in network byte order */ static __unused inline uint16_t diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 212209fb7e3..55b05b1362b 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -87,8 +87,8 @@ int ieee80211_parse_edca_params_body(struct ieee80211com *, const u_int8_t *); int ieee80211_parse_edca_params(struct ieee80211com *, const u_int8_t *); int ieee80211_parse_wmm_params(struct ieee80211com *, const u_int8_t *); -enum ieee80211_cipher ieee80211_parse_rsn_cipher(const u_int8_t[]); -enum ieee80211_akm ieee80211_parse_rsn_akm(const u_int8_t[]); +enum ieee80211_cipher ieee80211_parse_rsn_cipher(const u_int8_t *); +enum ieee80211_akm ieee80211_parse_rsn_akm(const u_int8_t *); int ieee80211_parse_rsn_body(struct ieee80211com *, const u_int8_t *, u_int, struct ieee80211_rsnparams *); int ieee80211_save_ie(const u_int8_t *, u_int8_t **); diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 3f32a4729d6..6f70643e4ce 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -271,7 +271,7 @@ void arp_rtrequest(struct ifnet *, int, struct rtentry *); void ether_fakeaddr(struct ifnet *); int ether_addmulti(struct ifreq *, struct arpcom *); int ether_delmulti(struct ifreq *, struct arpcom *); -int ether_multiaddr(struct sockaddr *, u_int8_t[], u_int8_t[]); +int ether_multiaddr(struct sockaddr *, u_int8_t *, u_int8_t *); void ether_ifattach(struct ifnet *); void ether_ifdetach(struct ifnet *); int ether_ioctl(struct ifnet *, struct arpcom *, u_long, caddr_t);