Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1685392rdb; Sat, 3 Feb 2024 18:36:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO2O2E0Plt2VrmEjv2vuI1PBjAyYlhdpH9RoDVKGCxvzBSaGsMzLGc3HOGaHiIJq+s8op2 X-Received: by 2002:a05:620a:5658:b0:783:6943:26d9 with SMTP id vw24-20020a05620a565800b00783694326d9mr9519201qkn.72.1707014160062; Sat, 03 Feb 2024 18:36:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707014160; cv=pass; d=google.com; s=arc-20160816; b=Jjqg7pa4yX75TcaFj7TLZDIaJJpOJvLzz3AyaPdJblGCcHihXJi5oTHUEFxHbbTqh9 2VV2OK/dsGwijG8qjKK6tdMM0HM73slFpTP1eA2/FuX1p3QzH1CvLqmgsc7WS6+z5VMl 7Mwcj2AuJSoU0ikMvA2Cb6LQDNTwvG4KM+SpwNi3FtRzvlf0TeDPXfBIn3pjfHFvL5dN hD4lwNeDIlZF9mj4tWtP+FpmsCXJrOZ1UyXrd1yUtbPxTQjwXZm3kCNPKG6XhRTrHqX5 1eSmdKzlLzf4PEOha6QxrsmQLT0TqOjAdNjTFEXWVYKhq8teU5AvERPs0nAMvBvNP0lR 9JGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=b7S8ENIwTw6+9bm+IefdHUPbMFwYSdb9IyEZNWuDgq0=; fh=IBcHDj2MNRFph+JA7YnMzWK7bn9XFlWuz5NdDSJGs6Y=; b=UXVIOG57kS+gjGMeCjd1yZHJ7wukL582LRqgKzMXtEf/7xWe1o9ZljqUDzfrIeL0Pd jwIu6iwWGBdLmtR5JgnMfH9Ei6dRvq+5nfv5Cd2hM9s/nV9nmsw5H9x412jXZwZV+xlq sBTdUFi17AU9JAJWBCC9fs2juUR9R+p3ANSDS1bAEdlzIE5Ax39hQneZhwGuzaldxqmw Gj0YXjoBKB7xedL9fBnMDlbv9me9nKCtAz9q3m78GOh4Qqc6PsgY7NNakCOJ4ciV2Xws MjCd+GicFuZ/McKlN0DaF+1NqtKNfdzVk+XNeMxCOic2xAVqK0iWEBL764xX2pRgqHiO MKtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bwlXnTLH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-51382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCXLr9hVp+UgTyzXVyJSXsLxeGY3K4GY0f61r/HJm3ULv/7/q/YllZ4QfWjj0I6o28D1YN+zvImTIj6imOj84GqaODOcFkFpykaCUBAUkw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z1-20020ae9e601000000b007855e7a7008si3748606qkf.462.2024.02.03.18.35.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 18:36:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bwlXnTLH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-51382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CDB2D1C21E0E for ; Sun, 4 Feb 2024 02:35:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B4C010FF; Sun, 4 Feb 2024 02:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bwlXnTLH" Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01F531115 for ; Sun, 4 Feb 2024 02:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707014151; cv=none; b=MP2GPiuOZ9MfrpGkUEpZwqmplqpzx8d/lAt7sFKg1rgwzyzVr54txfXoK8fjUwohDCTBDMKKipXjw1KaJ8C0s+i5Xj1TRQW7/wteuaFGt4Sbg2FVaLuR+uFBWYQlwvCRajbjZhfFFPLW8F+piKBbErWVWKPB0K5pWbhC3H2AIFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707014151; c=relaxed/simple; bh=eXGrpUkM4UG4cBvAJQ7Qgo/L2pXhU3blLDwhWRms55k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=h4K+Ands7rZVgrN//l2M3L3k43XLZi2HAukWnWab5IhLVXXDXDeGvZCLIVaI94hN8BFIdoNqm+nAqabSNRfaF3Cunc4uf7pltEyLyC5gukqvAxgGC6iukfqALr0np9K3F9DbuU7bo3qoG01fQWHDjjJ5a7FyGIiWXrpVWDsk9C0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bwlXnTLH; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707014146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=b7S8ENIwTw6+9bm+IefdHUPbMFwYSdb9IyEZNWuDgq0=; b=bwlXnTLHBbiARtjYG0PC/ic2kQthw/7x4CWl2f9jvhImeSZFCI9NAI7uk8QkKk+ev6OSyB RXp3HsUXJ9EnTkNIMBGAIg1vtq1zlhebAxQ2550ZDmOjNAoAl6X/AkoSUWc4Dqh3kncgPw mptpAmoAGFUTggvx4xNnw8JnyV0Cp8U= From: George Guo To: Jakub Kicinski , Paul Moore , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: George Guo , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] netlabel: cleanup struct netlbl_lsm_catmap Date: Sun, 4 Feb 2024 10:35:31 +0800 Message-Id: <20240204023531.2225264-1-dongtai.guo@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: George Guo Simplify the code from macro NETLBL_CATMAP_MAPTYPE to u64, and fix warning "Macros with complex values should be enclosed in parentheses" on "#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01", which is modified to "#define NETLBL_CATMAP_BIT ((u64)0x01)". Signed-off-by: George Guo --- V2: Yes, I understand what you are saying. Actually, there is a compile warnings on "#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01" which is missing parentheses. --- include/net/netlabel.h | 7 +++---- net/netlabel/netlabel_kapi.c | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/net/netlabel.h b/include/net/netlabel.h index d74f21f528de..0d04a8ae3811 100644 --- a/include/net/netlabel.h +++ b/include/net/netlabel.h @@ -145,15 +145,14 @@ struct netlbl_lsm_cache { * processing. * */ -#define NETLBL_CATMAP_MAPTYPE u64 #define NETLBL_CATMAP_MAPCNT 4 -#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8) +#define NETLBL_CATMAP_MAPSIZE (sizeof(u64) * 8) #define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \ NETLBL_CATMAP_MAPCNT) -#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01 +#define NETLBL_CATMAP_BIT ((u64)0x01) struct netlbl_lsm_catmap { u32 startbit; - NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT]; + u64 bitmap[NETLBL_CATMAP_MAPCNT]; struct netlbl_lsm_catmap *next; }; diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index 27511c90a26f..7b844581ebee 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -610,7 +610,7 @@ int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset) struct netlbl_lsm_catmap *iter; u32 idx; u32 bit; - NETLBL_CATMAP_MAPTYPE bitmap; + u64 bitmap; iter = _netlbl_catmap_getnode(&catmap, offset, _CM_F_WALK, 0); if (iter == NULL) @@ -666,8 +666,8 @@ int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset) struct netlbl_lsm_catmap *prev = NULL; u32 idx; u32 bit; - NETLBL_CATMAP_MAPTYPE bitmask; - NETLBL_CATMAP_MAPTYPE bitmap; + u64 bitmask; + u64 bitmap; iter = _netlbl_catmap_getnode(&catmap, offset, _CM_F_WALK, 0); if (iter == NULL) @@ -857,7 +857,7 @@ int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap, offset -= iter->startbit; idx = offset / NETLBL_CATMAP_MAPSIZE; - iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap + iter->bitmap[idx] |= (u64)bitmap << (offset % NETLBL_CATMAP_MAPSIZE); return 0; -- 2.34.1