Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp641846imm; Mon, 2 Jul 2018 19:30:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgper5aBdEDMDMrJwrv9WdwEUVX2gi2wsBYUi0wcxICiYKGVlsXkkze+DpRhqtO2ZZCtpxGNs X-Received: by 2002:a62:3f44:: with SMTP id m65-v6mr20038922pfa.98.1530585019495; Mon, 02 Jul 2018 19:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530585019; cv=none; d=google.com; s=arc-20160816; b=BjGKeb549jyYxjzCe+AVfNv8F4WqRQ7zsqwcxLqeoMmc5WxmmM/BvhF1yG0uTJ0LDP sYnhmhr+PycWujELssga3WsriU5PCmGsHgBAJ5i/Bpea2EvAbA8IvSxx2zQobH2OfYZB 0WNpBMEBpKQlrnn8Rjb9AK+P/IhXZrY4H7fKaZagnQ9Nd/m2ga0ECKQXghsqTafJY41g g/lPWc49DE+uXzL6pFsy4VRoRBgm5VJSNzhfKSV9OL2xk6ZKJ2SwCSsuHJ2xbHF/IO5h c6sHk7i5P9qfTeEySRCiaFFItnaPQ4GB356HZBRNjQD5igIPeZa9lTY0MIBg3Dfm30sI 2T1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=M31KbJms1xOnmYV17DW12Z4mjsuwP4CrqAdqv6ieT20=; b=KY6PPEtUhnKTag5bJmL+HEzoEGM2r9rhIPLmLGPyBapf+Jsk+BTaBT0KwzVQ6JzGXh 2RgGPeqTRau0CwvqGXyXuIH8F358hQpfhhiJV6AdFsmy2mNesIl+gveJAqes1Tlpj7jL +6YTJla8biZS6BaOptMM5ld+N5zR3oeUsCDTSprLFRj0EwHMnKgiI5n807p0vlTrb7Rm 23A/JRFdzBr8ScZdoKulWSW+aAzzOsEoLq5BCsK1eGLHlnAxILxcFj6wL94b34Ima5KV 4QSaOGpJ6S6CgsbNS9JcGhrn+QcYQ61eCKh/6ge05ZfdWTCaE+AdwlOfSMpcM6SaczCN yEuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3-v6si27723pld.39.2018.07.02.19.30.04; Mon, 02 Jul 2018 19:30:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753838AbeGCC2Z (ORCPT + 99 others); Mon, 2 Jul 2018 22:28:25 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:53592 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753706AbeGCC2X (ORCPT ); Mon, 2 Jul 2018 22:28:23 -0400 Received: from kilobyte by tartarus.angband.pl with local (Exim 4.89) (envelope-from ) id 1faB35-00075d-GI; Tue, 03 Jul 2018 04:28:11 +0200 Date: Tue, 3 Jul 2018 04:28:11 +0200 From: Adam Borowski To: Kees Cook Cc: Andrew Morton , Matthew Wilcox , Eric Biggers , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kernel.h: Documentation for roundup() vs round_up() Message-ID: <20180703022811.6v4dsqtcn5i6mt5i@angband.pl> References: <20180703021654.GA42417@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180703021654.GA42417@beast> X-Junkbait: aaron@angband.pl, zzyx@angband.pl User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: kilobyte@angband.pl X-SA-Exim-Scanned: No (on tartarus.angband.pl); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 02, 2018 at 07:16:54PM -0700, Kees Cook wrote: > Things like commit 3619dec5103d ("dh key: fix rounding up KDF output > length") expose the lack of explicit documentation for roundup() vs > round_up(). At least we can try to document it better if anyone goes > looking. > > Signed-off-by: Kees Cook > --- > +/** > + * round_up - round up to next specified power of 2 > + * @x: the value to round > + * @y: multiple to round up to (must be a power of 2) ^^^^^^^^^^^^^^^^^^^^ This matches the description -- so far, good. > + * > + * Rounds @x up to next multiple of @y (which must be a power of 2). > + * To perform arbitrary rounding up, use roundup() below. > + */ > +/** > + * roundup - round up to the next specified multiple > + * @x: the value to up > + * @y: multiple to round up to (must be a power of 2) ^^^^^^^^^^^^^^^^^^^^ But isn't this supposed to differ from the above? > + * > + * Rounds @x up to next multiple of @y. If @y will always be a power > + * of 2, consider using the faster round_up(). > + * > + * The `const' here prevents gcc-3.3 from calling __divdi3 > + */ > #define roundup(x, y) ( \ > { \ > const typeof(y) __y = y; \ > (((x) + (__y - 1)) / __y) * __y; \ > } \ Meow! -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢰⠒⠀⣿⡁ Imagine there are bandits in your house, your kid is bleeding out, ⢿⡄⠘⠷⠚⠋⠀ the house is on fire, and seven big-ass trumpets are playing in the ⠈⠳⣄⠀⠀⠀⠀ sky. Your cat demands food. The priority should be obvious...