Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp78169pxk; Fri, 11 Sep 2020 00:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykx7rqXLdOgjbiy1DfbBUOtkx/+uOD6d99mQLLgMMigOsBLHUalX/c55ic5Cs86IWuxFAS X-Received: by 2002:a17:906:7cb:: with SMTP id m11mr799040ejc.41.1599809156683; Fri, 11 Sep 2020 00:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599809156; cv=none; d=google.com; s=arc-20160816; b=v02RlfBHW6TZ6OWPE3QX0aUneAJ8RHdm3n9LSLfNyMlti5BvOLU5G+TmBNApWViMDn NKKjk1hBlIO8GeMjP63rAaID+lXv4tUSqgZ3TVI5ND3dV+drl5pd+O+anGryjsFNyJwf HGDQy1Yo2Gr+4A7m3oiJtbkuiAzu8U6o1Id+NnxpyK216nyjQf4Pvjpv8AZLNglVkFtM EmTSzwQ4alRF4VWWk/sMZX8NNJWi3Nmlcn0jEdLsJCkphv02ou7uZfVGpU8FUDpsAcEC O95yd6/IKwm+zN679k955aTY0oZWVe10/t/n2/x9pTgDsM3gOQUdgA4szYmAytIENQpc OVWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:dkim-signature; bh=NmBNH8hRQYjTI1ofR4EhVv+sfyRMCuK+r0fsinWUPrc=; b=noy+9R68spSJpdNadTbp8VaW82dwqm6jSqcrF1oy/g2MwBxC/uRBqg/yJkSAJ3guLY AKcreLl1Wq8XiIHfvVeIJbpA3XgICPzFYHBaEmRYSF6er4Ozat3m44YMBrcoWwJLEUYq ykwiZMWc/2SJlgKFF1HaS5vdp2kO+fPeMEQHVWCLv5RQ3P6oKelCpIa79hgpT9D+h6Cl 1Ad2tX0+hqBBba9iQiD5udElYE1hI0eqlkRQ1W4P1lJy49kQ3p6aHDUWFEkN4G3TqQFk gZ+aov1/GfZH83r7NbDcDKGNJU96fqVroMKP0ySOx3ptyt7n5aWBwAmVVydow7VIqcrQ SvOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P3LKLf2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si701053ejr.4.2020.09.11.00.25.33; Fri, 11 Sep 2020 00:25:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P3LKLf2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725807AbgIKHY5 (ORCPT + 99 others); Fri, 11 Sep 2020 03:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbgIKHYt (ORCPT ); Fri, 11 Sep 2020 03:24:49 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E50C061573; Fri, 11 Sep 2020 00:24:49 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a17so10413805wrn.6; Fri, 11 Sep 2020 00:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NmBNH8hRQYjTI1ofR4EhVv+sfyRMCuK+r0fsinWUPrc=; b=P3LKLf2u5BwvfB3TeHEkau8iFL8hxkHQKfbu0orIo5R9Dz6S4hETvgODwe7mJXGMUT ZtufnGS/ZG1Y8aoj/1t5JnbOgdvb7oczi10/EXDNtqVRcNKL1ta2zD+kF7jMDl6lfUm7 6Cw9nuc59Z/5LUYbiQupCKjsj3M+yJNhScRGPBg6tJDhVsGuJwcYGeaEdWfqNO9NBKZb mdgiTpNKh1S470qEarBwJdC+j0rEbnjxGlbIG0nQ+nRIxUR1I7GPlEI7rWC+2DDM0kb4 bX0yNqXi5J8cKkmLo3xSAbT45QbhbfGYTWwg6nIclcVZM0HWTQsW5LEkt4ltTzMk938n 8+FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NmBNH8hRQYjTI1ofR4EhVv+sfyRMCuK+r0fsinWUPrc=; b=q2T8HuomUdiWY+bddrOETHaIRQgS2vs7TxshA7ijaOpXOLi97HC1tT68tHptekh2xM Vti4uQFvJicy8j9SapmYXPbOI03VdEMJDfc7NSZRqD+7ZYRp2K1Z+YtrWtgmbTUdDWE/ JEDv/zRi3oFa+eq7OeZLtOoWRwosmTL5cjnE4DW6aECXLwrCx9dN9WC3F8MBbfLy95oz EKLZCEbH1xfyprp/X0TfR1W4nKQlyb0sRVMGmo9Sp9Gsn2xCrm35PW72BzjbkksVzoYX YeUCr7k8MtRaPnEhDSJ9Bcjh6y/LIxiqaT0OShvVktsYhctLR9jQgtBZh/2FLQzlr281 Ua8Q== X-Gm-Message-State: AOAM5325E4ZGV7qFWmq9bXfmtdhB7EZhGdFJ0NRyrO7o5babstbAjSx2 MMU5/xY7I5myWHB1/eYBtbpN4Yd7RxE= X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr620992wrq.83.1599809087859; Fri, 11 Sep 2020 00:24:47 -0700 (PDT) Received: from ?IPv6:2001:a61:2479:6801:d8fe:4132:9f23:7e8f? ([2001:a61:2479:6801:d8fe:4132:9f23:7e8f]) by smtp.gmail.com with ESMTPSA id h204sm2469147wmf.35.2020.09.11.00.24.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 00:24:47 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/24] ioctl_ns.2: Remove unneeded cast To: Alejandro Colomar References: <20200910211344.3562-1-colomar.6.4.3@gmail.com> <20200910211344.3562-11-colomar.6.4.3@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: Date: Fri, 11 Sep 2020 09:24:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200910211344.3562-11-colomar.6.4.3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On 9/10/20 11:13 PM, Alejandro Colomar wrote: > Both major(3) and minor(3) return an 'unsigned int', > so there is no need to use a 'long' for printing. > Moreover, it should have been 'unsigned long', > as "%lx" expects an unsigned type. This may be true on Linux, but is not true on other systems. For example, on HP-UX, according to one header file I'm looking at, the return value is 'long'. These kinds of casts are intended to improve code portability across UNIX implementations, so I think they should stay (although, I do wonder if they would be even better as casts to 'unsigned long') Thanks, Michael > Signed-off-by: Alejandro Colomar > --- > man2/ioctl_ns.2 | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/man2/ioctl_ns.2 b/man2/ioctl_ns.2 > index 818dde32c..bf832a2c7 100644 > --- a/man2/ioctl_ns.2 > +++ b/man2/ioctl_ns.2 > @@ -316,9 +316,8 @@ main(int argc, char *argv[]) > exit(EXIT_FAILURE); > } > printf("Device/Inode of owning user namespace is: " > - "[%lx,%lx] / %ld\en", > - (long) major(sb.st_dev), (long) minor(sb.st_dev), > - (long) sb.st_ino); > + "[%x,%x] / %ld\en", > + major(sb.st_dev), minor(sb.st_dev), (long) sb.st_ino); > > close(userns_fd); > } > @@ -345,9 +344,8 @@ main(int argc, char *argv[]) > perror("fstat\-parentns"); > exit(EXIT_FAILURE); > } > - printf("Device/Inode of parent namespace is: [%lx,%lx] / %ld\en", > - (long) major(sb.st_dev), (long) minor(sb.st_dev), > - (long) sb.st_ino); > + printf("Device/Inode of parent namespace is: [%x,%x] / %ld\en", > + major(sb.st_dev), minor(sb.st_dev), (long) sb.st_ino); > > close(parent_fd); > } > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/