From owner-svn-src-head@freebsd.org Tue Feb 27 15:51:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8100BF31A6B; Tue, 27 Feb 2018 15:51:25 +0000 (UTC) (envelope-from ctuffli@gmail.com) Received: from mail-wr0-x234.google.com (mail-wr0-x234.google.com [IPv6:2a00:1450:400c:c0c::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC50C7F7F2; Tue, 27 Feb 2018 15:51:24 +0000 (UTC) (envelope-from ctuffli@gmail.com) Received: by mail-wr0-x234.google.com with SMTP id k9so25387159wre.9; Tue, 27 Feb 2018 07:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=wM9/cBlrfEewxQeH0HAVaC7dPG/0L1EZjnyCvpWNmSU=; b=Jqce13uB9RFiTdyxV5LirMucWYnIPqqly9VJHLYYMoccXvyKUTEF7+9JXEwVpWiwB7 WG/dYYhn+vzJF9wViVBwPowsXRKR8pIN7pS/GO2z1f7Aga8u70HOHBDsHyR5b4qYp4Rc Cwwfg9Lb+X9/mhUIqu9yEg6yrKUz5lt1q7YSgVnYdkFFztVsUxB+tDYARrNQbDQJjU2S +Vc4v688BiFw/4FwHlzhmPTrkHq7UDpFyxoUxCB3qv32xZdTZCjg8kxaiwZ8Ana/AUNH PyX1VTDbvNn9YzOxBMkU29GlsYbV4rZi+iOF3awpbU5P61tNp7cNG4GcINKgOpB8QBHO 5btQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wM9/cBlrfEewxQeH0HAVaC7dPG/0L1EZjnyCvpWNmSU=; b=mc45cZ27OZxvuW00J2vlM/Qm6wMS8GK59u1xqPovU4YI0iKNhR65WgTln/4tnUZYRv JsvIjq0t+FKxJfdMKIErUJzsU5vS03aV01gohQHBu6fEFqe0jQSwBGnu7zmNXowE6IPg +kbg02okSzwVmpsT6QVUV+/kw5jYhpH1wZ3Hcf1WDFWYOWcsAw5ajW7WITFiCPU3+JMM 6bhyJW9Dg4iISqB5GbWn9VnEo3xe2evxr9X2316pwTo9OAh0IZuD1sS//gLl8FKc6H0p L+dbnVpzrV6Zm1OKUSefa5nE2nSLxuSjTCKiuPFB05l3sYID4r5FdqI8RjjNRUBZB2yg zVLg== X-Gm-Message-State: APf1xPDtMxTfQziRm0XNDLRN5pfq+P7TLI3pjS9O0cHOtaawL/Y/VDX1 YkEQgUz+Nk/ez6SxlFy5p1M8IeFMlpu0WatS8TcWdg== X-Google-Smtp-Source: AH8x2243IjKvKfy78H1xzgTZY3DFT2/hAaiinK22MLgCdbzLZzL/M8DxoWnU/k5tByUPngVLIVujRWB2RN3ZYe4gGYc= X-Received: by 10.223.179.211 with SMTP id x19mr12873790wrd.175.1519746683140; Tue, 27 Feb 2018 07:51:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.234.131 with HTTP; Tue, 27 Feb 2018 07:51:22 -0800 (PST) In-Reply-To: <1519322697.91697.138.camel@freebsd.org> References: <201802221747.w1MHlGJS032223@repo.freebsd.org> <1519322697.91697.138.camel@freebsd.org> From: Chuck Tuffli Date: Tue, 27 Feb 2018 07:51:22 -0800 Message-ID: Subject: Re: svn commit: r329830 - head/sbin/nvmecontrol To: Ian Lepore Cc: Alan Somers , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Feb 2018 15:51:25 -0000 On Thu, Feb 22, 2018 at 10:04 AM, Ian Lepore wrote: > On Thu, 2018-02-22 at 17:47 +0000, Alan Somers wrote: >> Author: asomers >> Date: Thu Feb 22 17:47:16 2018 >> New Revision: 329830 >> URL: https://svnweb.freebsd.org/changeset/base/329830 >> >> Log: >> nvmecontrol: fix build on amd64/clang >> >> Broken by: 329824 >> Sponsored by: Spectra Logic Corp >> >> Modified: >> head/sbin/nvmecontrol/identify.c >> >> Modified: head/sbin/nvmecontrol/identify.c >> ============================================================================== >> --- head/sbin/nvmecontrol/identify.c Thu Feb 22 17:09:26 2018 (r329829) >> +++ head/sbin/nvmecontrol/identify.c Thu Feb 22 17:47:16 2018 (r329830) >> @@ -112,7 +112,7 @@ print_controller(struct nvme_controller_data *cdata) >> if (cdata->mdts == 0) >> printf("Unlimited\n"); >> else >> - printf("%ld\n", PAGE_SIZE * (1 << cdata->mdts)); >> + printf("%d\n", PAGE_SIZE * (1 << cdata->mdts)); >> printf("Controller ID: 0x%02x\n", cdata->ctrlr_id); >> printf("\n"); > > If cdata->mdts > 19 that'll overflow 32 bits. I'm not sure if that can > happen in the real world or not. If so, maybe it'd be better to do > > printf("%ju\n", PAGE_SIZE * ((uintmax_t)1 << cdata->mdts)); > > -- Ian Yes, MDTS is an 8 bit value and thus can overflow in the way you describe, but typically, it is in the range of 5-12. Also note that multiplying by PAGE_SIZE isn't quite correct as MDTS is in units of the NVMe Controller's advertised minimum page size (i.e. CAP.MPSMIN). Most Controllers will default to a value of 4096 for MPSMIN, so practically, this code will usually work. --chuck