From nobody Sat Feb 12 00:10:36 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6D95D19AE6EB; Sat, 12 Feb 2022 00:10:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JwW8r63Sfz57sn; Sat, 12 Feb 2022 00:10:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644624637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rxYk2feepVT2YIY7bAnt9Tf2Se6+V2zjWsLBOWOwo6w=; b=wRErDPBKY5DS6r0lZW9DthIQvjl2ZZu3shHbQjJheWUuqdQRpmNhey7t+/lhTfk82E9cAd QQ848rkD5/7iG+eBN+WI/L0WhfwVdBxsE8vtVfEC8j1YRePb/1MitAnYa7m/sIqD34mMGM NEBs4Mh7VKK6BVPSW6yZo6cgbc32+pao1PE6NxC6SdHTNjyj/od2x+xOE1ybuHtNAYS5gp TDPFlgh9aHAON1yxn1fAqxp10nrrsv8XrlIRcS76rDoPpFO26ECcKTOd6S5L1czq6EDMD7 b4pJrlJ9NZ9OwVyj0Z9c1FGhHmXJVPS9O1whR9gegVjJRlDahbqmQR/ckHc6nQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8697A1D6D8; Sat, 12 Feb 2022 00:10:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21C0AadT017561; Sat, 12 Feb 2022 00:10:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21C0AatV017560; Sat, 12 Feb 2022 00:10:36 GMT (envelope-from git) Date: Sat, 12 Feb 2022 00:10:36 GMT Message-Id: <202202120010.21C0AatV017560@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: dba02df30d53 - main - Cast pointer to uintptr_t to avoid alignment warnings. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dba02df30d536922727a7ea509514462452a247a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644624637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rxYk2feepVT2YIY7bAnt9Tf2Se6+V2zjWsLBOWOwo6w=; b=tiafDX+xTBe8azYSDF0kPM4uJDa6cB+SYPH/swJuaTUG0ru8Uj4/0KIj6xBIepUesXbiwi D10CpOFaW18gFm1TaurQwr7r3Kt+0dqtX47z2UF3O2tZ8ALczPVMIV3ZtTxlc7kOctjtdq kjxabmRDIgr9i8rg642Olp+McWepJDuyM3ZYyO00608hfC0cG/OgZ974Rlg6DXR4EprZsR 1c41LWFDCg+DEWGhq1zXzum7FTiRz5d5O5dB4p/lnP8cQVFQ3U8ACcfkas0+292oTTkPbM GyoVEGBziIiZe9k6EkPYEdihQQ6gPhE/P0Si6sh4GiqU6KWdsLpEqHMhW9/rIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644624637; a=rsa-sha256; cv=none; b=mHZMLTnEAbvK7rSAIjWlruOICDO+VLkcUH5U+T6aIOawBhzJssIi8AYAaJi+nFmTSIJVeI EP2MZj4TVc3gZUvqLqSHmtlmWl2aipjbW1tr2mJBwUhCA4XgbrgCLrLmcnwe7HEDmcDJuJ OA69VM/8g3jS866+BldmbUYU3y+CwRVtpGoWXHUp4jO+JFBRIR25cwtS0Y65j+Mptj6vKr pDeBMNQHPeZgzViXHF2azFO0H9QekgHpsbn57acQ86Eo0a7SFgdNhjMoB+QQnIrfea1CWS shiFT17BM0kcmyYlU61HIa74FgrROmeImowTXY9oIL513SYOSIHAEBoVrJnaKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=dba02df30d536922727a7ea509514462452a247a commit dba02df30d536922727a7ea509514462452a247a Author: John Baldwin AuthorDate: 2022-02-12 00:04:52 +0000 Commit: John Baldwin CommitDate: 2022-02-12 00:04:52 +0000 Cast pointer to uintptr_t to avoid alignment warnings. Both struct ip and struct udphdr both have an aligment of 2, but the cast from struct ip to a uint32_t pointer confused GCC 9 into raising the required alignment to 4 and then raising a -Waddress-of-packed-member error when casting to struct udphdr. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D31941 --- tests/sys/netinet/libalias/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sys/netinet/libalias/util.c b/tests/sys/netinet/libalias/util.c index 681c3b20ee41..14ba196a59a5 100644 --- a/tests/sys/netinet/libalias/util.c +++ b/tests/sys/netinet/libalias/util.c @@ -109,9 +109,9 @@ ip_packet(u_char protocol, size_t len) struct udphdr * set_udp(struct ip *p, u_short sport, u_short dport) { - uint32_t *up = (void *)p; - struct udphdr *u = (void *)&(up[p->ip_hl]); - int payload = ntohs(p->ip_len) - 4*p->ip_hl; + int hlen = p->ip_hl << 2; + struct udphdr *u = (struct udphdr *)((uintptr_t)p + hlen); + int payload = ntohs(p->ip_len) - hlen; REQUIRE(payload >= (int)sizeof(*u)); p->ip_p = IPPROTO_UDP;