Index: sys/arch/amd64/amd64/identcpu.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/arch/amd64/amd64/identcpu.c,v retrieving revision 1.121 diff -u -p -u -p -r1.121 identcpu.c --- sys/arch/amd64/amd64/identcpu.c 2 Nov 2021 23:30:15 -0000 1.121 +++ sys/arch/amd64/amd64/identcpu.c 20 Jan 2022 13:19:56 -0000 @@ -854,7 +854,7 @@ cpu_topology(struct cpu_info *ci) ci->ci_pkg_id = apicid >> core_bits; /* Get rid of the package bits */ - core_mask = (1 << core_bits) - 1; + core_mask = (1U << core_bits) - 1; thread_id = apicid & core_mask; /* Cut logical thread_id into core id, and smt id in a core */ @@ -872,14 +872,14 @@ cpu_topology(struct cpu_info *ci) max_coreid = ((eax >> 26) & 0x3f) + 1; /* SMT */ smt_bits = mask_width(max_apicid / max_coreid); - smt_mask = (1 << smt_bits) - 1; + smt_mask = (1U << smt_bits) - 1; /* Core */ core_bits = log2(max_coreid); - core_mask = (1 << (core_bits + smt_bits)) - 1; + core_mask = (1U << (core_bits + smt_bits)) - 1; core_mask ^= smt_mask; /* Pkg */ pkg_bits = core_bits + smt_bits; - pkg_mask = -1 << core_bits; + pkg_mask = ~0U << core_bits; ci->ci_smt_id = apicid & smt_mask; ci->ci_core_id = (apicid & core_mask) >> smt_bits; Index: sys/arch/amd64/conf/GENERIC =================================================================== RCS file: /mount/openbsd/cvs/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.510 diff -u -p -u -p -r1.510 GENERIC --- sys/arch/amd64/conf/GENERIC 4 Jan 2022 05:50:43 -0000 1.510 +++ sys/arch/amd64/conf/GENERIC 20 Jan 2022 13:19:56 -0000 @@ -381,23 +381,23 @@ wsmouse* at pms? mux 0 #mmuagp* at pchb? # amd64 mmu agp. #agp* at mmuagp? -inteldrm* at pci? # Intel i915, i945 DRM driver -intagp* at inteldrm? -agp* at intagp? -drm0 at inteldrm? primary 1 -drm* at inteldrm? -wsdisplay0 at inteldrm? primary 1 -wsdisplay* at inteldrm? mux -1 -radeondrm* at pci? # ATI Radeon DRM driver -drm0 at radeondrm? primary 1 -drm* at radeondrm? -wsdisplay0 at radeondrm? primary 1 -wsdisplay* at radeondrm? mux -1 -amdgpu* at pci? -drm0 at amdgpu? primary 1 -drm* at amdgpu? -wsdisplay0 at amdgpu? primary 1 -wsdisplay* at amdgpu? mux -1 +#inteldrm* at pci? # Intel i915, i945 DRM driver +#intagp* at inteldrm? +#agp* at intagp? +#drm0 at inteldrm? primary 1 +#drm* at inteldrm? +#wsdisplay0 at inteldrm? primary 1 +#wsdisplay* at inteldrm? mux -1 +#radeondrm* at pci? # ATI Radeon DRM driver +#drm0 at radeondrm? primary 1 +#drm* at radeondrm? +#wsdisplay0 at radeondrm? primary 1 +#wsdisplay* at radeondrm? mux -1 +#amdgpu* at pci? +#drm0 at amdgpu? primary 1 +#drm* at amdgpu? +#wsdisplay0 at amdgpu? primary 1 +#wsdisplay* at amdgpu? mux -1 pcppi0 at isa? Index: sys/arch/amd64/conf/GENERIC.MP =================================================================== RCS file: /mount/openbsd/cvs/src/sys/arch/amd64/conf/GENERIC.MP,v retrieving revision 1.16 diff -u -p -u -p -r1.16 GENERIC.MP --- sys/arch/amd64/conf/GENERIC.MP 9 Feb 2021 14:06:19 -0000 1.16 +++ sys/arch/amd64/conf/GENERIC.MP 20 Jan 2022 13:19:56 -0000 @@ -5,5 +5,6 @@ include "arch/amd64/conf/GENERIC" option MULTIPROCESSOR #option MP_LOCKDEBUG #option WITNESS +option KUBSAN cpu* at mainbus? Index: sys/dev/pci/if_em_hw.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/dev/pci/if_em_hw.c,v retrieving revision 1.113 diff -u -p -u -p -r1.113 if_em_hw.c --- sys/dev/pci/if_em_hw.c 9 Jan 2022 05:42:50 -0000 1.113 +++ sys/dev/pci/if_em_hw.c 20 Jan 2022 13:19:56 -0000 @@ -7622,7 +7622,7 @@ em_read_part_num(struct em_hw *hw, uint3 return -E1000_ERR_EEPROM; } /* Save word 0 in upper half of part_num */ - *part_num = (uint32_t) (eeprom_data << 16); + *part_num = (uint32_t)eeprom_data << 16; /* Get word 1 from EEPROM */ if (em_read_eeprom(hw, ++offset, 1, &eeprom_data) < 0) { Index: sys/dev/pci/if_ix.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/dev/pci/if_ix.c,v retrieving revision 1.180 diff -u -p -u -p -r1.180 if_ix.c --- sys/dev/pci/if_ix.c 27 Jul 2021 01:44:55 -0000 1.180 +++ sys/dev/pci/if_ix.c 20 Jan 2022 13:19:56 -0000 @@ -3400,8 +3400,8 @@ ixgbe_set_ivar(struct ix_softc *sc, uint entry += (type * 64); index = (entry >> 2) & 0x1F; ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index)); - ivar &= ~(0xFF << (8 * (entry & 0x3))); - ivar |= (vector << (8 * (entry & 0x3))); + ivar &= ~((uint32_t)0xFF << (8 * (entry & 0x3))); + ivar |= ((uint32_t)vector << (8 * (entry & 0x3))); IXGBE_WRITE_REG(&sc->hw, IXGBE_IVAR(index), ivar); break; @@ -3413,14 +3413,14 @@ ixgbe_set_ivar(struct ix_softc *sc, uint if (type == -1) { /* MISC IVAR */ index = (entry & 1) * 8; ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC); - ivar &= ~(0xFF << index); - ivar |= (vector << index); + ivar &= ~((uint32_t)0xFF << index); + ivar |= ((uint32_t)vector << index); IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar); } else { /* RX/TX IVARS */ index = (16 * (entry & 1)) + (8 * type); ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(entry >> 1)); - ivar &= ~(0xFF << index); - ivar |= (vector << index); + ivar &= ~((uint32_t)0xFF << index); + ivar |= ((uint32_t)vector << index); IXGBE_WRITE_REG(hw, IXGBE_IVAR(entry >> 1), ivar); } Index: sys/dev/pci/ixgbe.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/dev/pci/ixgbe.c,v retrieving revision 1.26 diff -u -p -u -p -r1.26 ixgbe.c --- sys/dev/pci/ixgbe.c 2 Mar 2020 01:59:01 -0000 1.26 +++ sys/dev/pci/ixgbe.c 20 Jan 2022 13:19:56 -0000 @@ -2378,7 +2378,7 @@ int32_t ixgbe_fc_enable_generic(struct i } /* Configure pause time (2 TCs per register) */ - reg = hw->fc.pause_time * 0x00010001; + reg = (uint32_t)hw->fc.pause_time * 0x00010001; for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); Index: sys/dev/pci/ixgbe_82598.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/dev/pci/ixgbe_82598.c,v retrieving revision 1.19 diff -u -p -u -p -r1.19 ixgbe_82598.c --- sys/dev/pci/ixgbe_82598.c 9 Jan 2022 05:42:56 -0000 1.19 +++ sys/dev/pci/ixgbe_82598.c 20 Jan 2022 13:19:56 -0000 @@ -544,7 +544,7 @@ int32_t ixgbe_fc_enable_82598(struct ixg } /* Configure pause time (2 TCs per register) */ - reg = hw->fc.pause_time * 0x00010001; + reg = (uint32_t)hw->fc.pause_time * 0x00010001; for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); Index: sys/kern/kern_descrip.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.204 diff -u -p -u -p -r1.204 kern_descrip.c --- sys/kern/kern_descrip.c 25 Oct 2021 10:24:54 -0000 1.204 +++ sys/kern/kern_descrip.c 20 Jan 2022 13:19:56 -0000 @@ -156,7 +156,7 @@ fd_inuse(struct filedesc *fdp, int fd) { u_int off = fd >> NDENTRYSHIFT; - if (fdp->fd_lomap[off] & (1 << (fd & NDENTRYMASK))) + if (fdp->fd_lomap[off] & (1U << (fd & NDENTRYMASK))) return 1; return 0; @@ -167,9 +167,9 @@ fd_used(struct filedesc *fdp, int fd) { u_int off = fd >> NDENTRYSHIFT; - fdp->fd_lomap[off] |= 1 << (fd & NDENTRYMASK); + fdp->fd_lomap[off] |= 1U << (fd & NDENTRYMASK); if (fdp->fd_lomap[off] == ~0) - fdp->fd_himap[off >> NDENTRYSHIFT] |= 1 << (off & NDENTRYMASK); + fdp->fd_himap[off >> NDENTRYSHIFT] |= 1U << (off & NDENTRYMASK); if (fd > fdp->fd_lastfile) fdp->fd_lastfile = fd; @@ -185,8 +185,8 @@ fd_unused(struct filedesc *fdp, int fd) fdp->fd_freefile = fd; if (fdp->fd_lomap[off] == ~0) - fdp->fd_himap[off >> NDENTRYSHIFT] &= ~(1 << (off & NDENTRYMASK)); - fdp->fd_lomap[off] &= ~(1 << (fd & NDENTRYMASK)); + fdp->fd_himap[off >> NDENTRYSHIFT] &= ~(1U << (off & NDENTRYMASK)); + fdp->fd_lomap[off] &= ~(1U << (fd & NDENTRYMASK)); #ifdef DIAGNOSTIC if (fd > fdp->fd_lastfile) Index: sys/kern/kern_sched.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/kern/kern_sched.c,v retrieving revision 1.73 diff -u -p -u -p -r1.73 kern_sched.c --- sys/kern/kern_sched.c 9 Sep 2021 18:41:39 -0000 1.73 +++ sys/kern/kern_sched.c 20 Jan 2022 13:19:57 -0000 @@ -262,7 +262,7 @@ setrunqueue(struct cpu_info *ci, struct p->p_p->ps_pid); TAILQ_INSERT_TAIL(&spc->spc_qs[queue], p, p_runq); - spc->spc_whichqs |= (1 << queue); + spc->spc_whichqs |= (1U << queue); cpuset_add(&sched_queued_cpus, p->p_cpu); if (cpuset_isset(&sched_idle_cpus, p->p_cpu)) @@ -286,7 +286,7 @@ remrunqueue(struct proc *p) TAILQ_REMOVE(&spc->spc_qs[queue], p, p_runq); if (TAILQ_EMPTY(&spc->spc_qs[queue])) { - spc->spc_whichqs &= ~(1 << queue); + spc->spc_whichqs &= ~(1U << queue); if (spc->spc_whichqs == 0) cpuset_del(&sched_queued_cpus, p->p_cpu); } @@ -757,21 +757,21 @@ void cpuset_add(struct cpuset *cs, struct cpu_info *ci) { unsigned int num = CPU_INFO_UNIT(ci); - atomic_setbits_int(&cs->cs_set[num/32], (1 << (num % 32))); + atomic_setbits_int(&cs->cs_set[num/32], (1U << (num % 32))); } void cpuset_del(struct cpuset *cs, struct cpu_info *ci) { unsigned int num = CPU_INFO_UNIT(ci); - atomic_clearbits_int(&cs->cs_set[num/32], (1 << (num % 32))); + atomic_clearbits_int(&cs->cs_set[num/32], (1U << (num % 32))); } int cpuset_isset(struct cpuset *cs, struct cpu_info *ci) { unsigned int num = CPU_INFO_UNIT(ci); - return (cs->cs_set[num/32] & (1 << (num % 32))); + return (cs->cs_set[num/32] & (1U << (num % 32))); } void Index: sys/kern/subr_pool.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/kern/subr_pool.c,v retrieving revision 1.234 diff -u -p -u -p -r1.234 subr_pool.c --- sys/kern/subr_pool.c 15 Jun 2021 05:24:46 -0000 1.234 +++ sys/kern/subr_pool.c 20 Jan 2022 13:19:57 -0000 @@ -961,7 +961,7 @@ pool_p_alloc(struct pool *pp, int flags, order = arc4random(); o = 0; } - if (ISSET(order, 1 << o++)) + if (ISSET(order, 1U << o++)) XSIMPLEQ_INSERT_TAIL(&ph->ph_items, pi, pi_list); else XSIMPLEQ_INSERT_HEAD(&ph->ph_items, pi, pi_list); Index: sys/kern/subr_prf.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/kern/subr_prf.c,v retrieving revision 1.104 diff -u -p -u -p -r1.104 subr_prf.c --- sys/kern/subr_prf.c 2 Jun 2021 00:39:25 -0000 1.104 +++ sys/kern/subr_prf.c 20 Jan 2022 13:19:57 -0000 @@ -570,14 +570,14 @@ snprintf(char *buf, size_t size, const c va_list ap; char *p; - p = buf + size - 1; - if (size < 1) - p = buf; + p = buf; + if (size > 0) + p += size - 1; va_start(ap, fmt); retval = kprintf(fmt, TOBUFONLY | TOCOUNT, &p, buf, ap); va_end(ap); if (size > 0) - *(p) = 0; /* null terminate */ + *p = '\0'; /* null terminate */ return(retval); } Index: sys/net/pfkeyv2_convert.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/net/pfkeyv2_convert.c,v retrieving revision 1.78 diff -u -p -u -p -r1.78 pfkeyv2_convert.c --- sys/net/pfkeyv2_convert.c 20 Dec 2021 15:59:09 -0000 1.78 +++ sys/net/pfkeyv2_convert.c 20 Jan 2022 13:19:57 -0000 @@ -432,13 +432,15 @@ import_flow(struct sockaddr_encap *flow, struct sadb_protocol *sab, struct sadb_protocol *ftype) { u_int8_t transproto = 0; - union sockaddr_union *src = (union sockaddr_union *)(ssrc + 1); - union sockaddr_union *dst = (union sockaddr_union *)(ddst + 1); - union sockaddr_union *srcmask = (union sockaddr_union *)(ssrcmask + 1); - union sockaddr_union *dstmask = (union sockaddr_union *)(ddstmask + 1); + union sockaddr_union *src, *dst, *srcmask, *dstmask; if (ssrc == NULL) return 0; /* There wasn't any information to begin with. */ + + src = (union sockaddr_union *)(ssrc + 1); + dst = (union sockaddr_union *)(ddst + 1); + srcmask = (union sockaddr_union *)(ssrcmask + 1); + dstmask = (union sockaddr_union *)(ddstmask + 1); bzero(flow, sizeof(*flow)); bzero(flowmask, sizeof(*flowmask)); Index: sys/net/rtsock.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/net/rtsock.c,v retrieving revision 1.323 diff -u -p -u -p -r1.323 rtsock.c --- sys/net/rtsock.c 16 Dec 2021 09:33:56 -0000 1.323 +++ sys/net/rtsock.c 20 Jan 2022 13:19:57 -0000 @@ -538,7 +538,7 @@ route_input(struct mbuf *m0, struct sock /* but RTM_DESYNC can't be filtered */ if (rtm->rtm_type != RTM_DESYNC) { if (rop->rop_msgfilter != 0 && - !(rop->rop_msgfilter & (1 << rtm->rtm_type))) + !(rop->rop_msgfilter & (1U << rtm->rtm_type))) goto next; if (ISSET(rop->rop_flagfilter, rtm->rtm_flags)) goto next; @@ -1426,7 +1426,7 @@ rtm_xaddrs(caddr_t cp, caddr_t cplim, st */ bzero(rtinfo->rti_info, sizeof(rtinfo->rti_info)); for (i = 0; i < sizeof(rtinfo->rti_addrs) * 8; i++) { - if ((rtinfo->rti_addrs & (1 << i)) == 0) + if ((rtinfo->rti_addrs & (1U << i)) == 0) continue; if (i >= RTAX_MAX || cp + sizeof(socklen_t) > cplim) return (EINVAL); @@ -1605,7 +1605,7 @@ rtm_msg1(int type, struct rt_addrinfo *r for (i = 0; i < RTAX_MAX; i++) { if (rtinfo == NULL || (sa = rtinfo->rti_info[i]) == NULL) continue; - rtinfo->rti_addrs |= (1 << i); + rtinfo->rti_addrs |= (1U << i); dlen = ROUNDUP(sa->sa_len); if (m_copyback(m, len, dlen, sa, M_NOWAIT)) { m_freem(m); @@ -1650,7 +1650,7 @@ again: if ((sa = rtinfo->rti_info[i]) == NULL) continue; - rtinfo->rti_addrs |= (1 << i); + rtinfo->rti_addrs |= (1U << i); dlen = ROUNDUP(sa->sa_len); if (cp) { bcopy(sa, cp, (size_t)dlen); Index: sys/netinet/in_pcb.h =================================================================== RCS file: /mount/openbsd/cvs/src/sys/netinet/in_pcb.h,v retrieving revision 1.121 diff -u -p -u -p -r1.121 in_pcb.h --- sys/netinet/in_pcb.h 25 Jan 2021 03:40:46 -0000 1.121 +++ sys/netinet/in_pcb.h 20 Jan 2022 13:19:57 -0000 @@ -226,9 +226,9 @@ struct inpcbtable { /* macros for handling bitmap of ports not to allocate dynamically */ #define DP_MAPBITS (sizeof(u_int32_t) * NBBY) #define DP_MAPSIZE (howmany(65536, DP_MAPBITS)) -#define DP_SET(m, p) ((m)[(p) / DP_MAPBITS] |= (1 << ((p) % DP_MAPBITS))) -#define DP_CLR(m, p) ((m)[(p) / DP_MAPBITS] &= ~(1 << ((p) % DP_MAPBITS))) -#define DP_ISSET(m, p) ((m)[(p) / DP_MAPBITS] & (1 << ((p) % DP_MAPBITS))) +#define DP_SET(m, p) ((m)[(p) / DP_MAPBITS] |= (1U << ((p) % DP_MAPBITS))) +#define DP_CLR(m, p) ((m)[(p) / DP_MAPBITS] &= ~(1U << ((p) % DP_MAPBITS))) +#define DP_ISSET(m, p) ((m)[(p) / DP_MAPBITS] & (1U << ((p) % DP_MAPBITS))) /* default values for baddynamicports [see ip_init()] */ #define DEFBADDYNAMICPORTS_TCP { \ Index: sys/netinet/ip_esp.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/netinet/ip_esp.c,v retrieving revision 1.193 diff -u -p -u -p -r1.193 ip_esp.c --- sys/netinet/ip_esp.c 23 Dec 2021 22:35:11 -0000 1.193 +++ sys/netinet/ip_esp.c 20 Jan 2022 13:19:57 -0000 @@ -1002,7 +1002,7 @@ checkreplaywindow(struct tdb *tdb, u_int wl = tl - window + 1; idx = (seq % TDB_REPLAYMAX) / 32; - packet = 1 << (31 - (seq & 31)); + packet = 1U << (31 - (seq & 31)); /* * We keep the high part intact when: Index: sys/netinet/tcp_var.h =================================================================== RCS file: /mount/openbsd/cvs/src/sys/netinet/tcp_var.h,v retrieving revision 1.136 diff -u -p -u -p -r1.136 tcp_var.h --- sys/netinet/tcp_var.h 28 Jan 2021 14:53:20 -0000 1.136 +++ sys/netinet/tcp_var.h 20 Jan 2022 13:19:57 -0000 @@ -104,7 +104,7 @@ struct tcpcb { #define TF_TMR_2MSL 0x20000000 /* 2*msl quiet time timer armed */ #define TF_TMR_REAPER 0x40000000 /* delayed cleanup timer armed, dead */ #define TF_TMR_DELACK 0x80000000 /* delayed ack timer armed */ -#define TF_TIMER TF_TMR_REXMT /* used to shift with TCPT values */ +#define TF_TIMER ((unsigned)TF_TMR_REXMT) /* used to shift with TCPT values */ struct mbuf *t_template; /* skeletal packet for transmit */ struct inpcb *t_inpcb; /* back pointer to internet pcb */