From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kmlkq-00050w-KW for mharc-grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmlkf-0004hf-73 for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:33 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:46904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmlkO-0000j6-89 for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:32 -0500 Received: by mail-ot1-x342.google.com with SMTP id w3so310169otp.13 for ; Tue, 08 Dec 2020 14:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xT+mLeWtnktLNoAur/gktOhZ0DxtSlI6JZ157Jo7rqo=; b=bK4e/GQQJVgjR+tguS/ftlLBG4YuRhNnVZ5sif5HJZ4JQq17FHLvyG5i74eOUHA7LL bQpAzTZKKtbQdtRMc3z6yN9gsHiA0QpTYcONxFh/ByQL5OIrPQG04URivJDedSdD/E9M hnEAUxSjKwQ+4sEXEhBYYi+QWV56+1IN6dxCrgo4+HeX0lw5V4kYRkry7PUEMMAgPzit J2mAggknV4Fxi8UOTFtij/Z6DXVMiNEl4d5VW9LlwdbeSnYuxeBFDHu/qSPj0rnBW7/S lr1qRrD3j131CEDQixA46lapcFWdwNPXHJ5s9PhFAXSrrOxWGjAdLQA1FamT3OMhn+4y PRbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xT+mLeWtnktLNoAur/gktOhZ0DxtSlI6JZ157Jo7rqo=; b=HB01+tzUSE5NWf61z6BmL8Ujrs+3L6WLdHV/Ip0w7Gbo2tCxaKZIgB7hI3eqR6kXRQ wdo45eUj3ojD0otBd8+59B/NB5pP3zAT8Hug556PNyc7DKCsBg8JGxc5j6wgl+2DtOJj wkMFESxGaMXlR3Dc+m/BHdOTutG6rZtF8zljti4RLZQ9zE7hdOt8QaUTvgk088gZ5yEi 1kvTPJL9nTGk33lR7n5EqmKACHZmACcdkqiG3sJ1Hh8K1jGedIE4rCKEr3whJnurx/B0 t6jISFTUdDe+6J0/eHzHe1r/W3kVtON2UXY4OkLYmbqFhhfiP2P/Bav6JIwQnTPAJnwN rA9Q== X-Gm-Message-State: AOAM532L/p6HNekWUMC0ToD+3MrUQOmAHweggBWYclyu0j3R3Ia5fiKL h6JRuWz+1u1v/sMk8wlzg9pcdzFoVM63UA== X-Google-Smtp-Source: ABdhPJz6GLaRHs2B6DKpYhgw80kHxmmJ3X2tru0jZEOjeQVKAkTdZvQFEOUhnUZOc1o9g/GeYzSLvQ== X-Received: by 2002:a05:6830:128a:: with SMTP id z10mr277642otp.3.1607467573196; Tue, 08 Dec 2020 14:46:13 -0800 (PST) Received: from crass-HP-ZBook-15-G2.attlocal.net ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id v8sm45538otp.10.2020.12.08.14.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:46:12 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn , Daniel Kiper Subject: [PATCH v8 02/18] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments Date: Tue, 8 Dec 2020 16:45:33 -0600 Message-Id: <17b1ef195345c3c1a673e19cbc39cf7171368a38.1607466704.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=development@efficientek.com; helo=mail-ot1-x342.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 22:46:33 -0000 This ensures that expected order of operations is preserved when arguments are expressions. Signed-off-by: Glenn Washburn Reviewed-by: Daniel Kiper Reviewed-by: Patrick Steinhardt --- include/grub/misc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grub/misc.h b/include/grub/misc.h index b7ca6dd58..780a34e90 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -28,10 +28,10 @@ #include #define ALIGN_UP(addr, align) \ - ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) + (((addr) + (typeof (addr)) (align) - 1) & ~((typeof (addr)) (align) - 1)) #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1)) #define ALIGN_DOWN(addr, align) \ - ((addr) & ~((typeof (addr)) align - 1)) + ((addr) & ~((typeof (addr)) (align) - 1)) #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } -- 2.27.0