From owner-svn-src-all@freebsd.org Wed Dec 2 05:03:58 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27050A341E0; Wed, 2 Dec 2015 05:03:58 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (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 B2F591F13; Wed, 2 Dec 2015 05:03:57 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by wmvv187 with SMTP id v187so237533677wmv.1; Tue, 01 Dec 2015 21:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=m1C/r/XbJRpoGi8p4wDC7JGzwl0AoSLBOr+6CKRa8rU=; b=SDKguVSABaIyJc45Qn5ZLjB4lPJqun1maQGCc23bc7FNjrvCmQE/B58wu/PUyjoUdY 2tF3smbc6LTkKX176tmsX32T3E3TY8j0CxZ1+FeRxeflnMpA1fL73aoW/6t4aL7v77x5 MBLegpLQSuz5iWMFkd3wWnRQlqcRvs41a/K2Q3iIQhdjAM2RYh2RPcC1iKV1vWQ0mY5P yE2/HDPm3gkwZA6DV3aA1c03V10cKJZy4VhAmDc1Uu+OWdOJiSRNxQpBdpJMCb1Gm5g+ zvfHbPY5DQdgy/K5YjuzcjpgfzqeEZ08Qx0KahR396zcQo2Dhf4FrZ2I7IPV55szNNOh qqtQ== MIME-Version: 1.0 X-Received: by 10.28.171.134 with SMTP id u128mr42809490wme.22.1449032636229; Tue, 01 Dec 2015 21:03:56 -0800 (PST) Received: by 10.27.10.199 with HTTP; Tue, 1 Dec 2015 21:03:56 -0800 (PST) In-Reply-To: References: <201512020211.tB22BcUB082864@repo.freebsd.org> Date: Tue, 1 Dec 2015 23:03:56 -0600 Message-ID: Subject: Re: svn commit: r291637 - head/cddl/contrib/opensolaris/cmd/plockstat From: Benjamin Kaduk To: Craig Rodrigues Cc: Bryan Drewery , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2015 05:03:58 -0000 On Tue, Dec 1, 2015 at 10:18 PM, Craig Rodrigues wrote: > On Tue, Dec 1, 2015 at 6:11 PM, Bryan Drewery > wrote: > > > - (void) snprintf(buf, size, "%#lx", addr); > > + (void) snprintf(buf, size, "%#lx", (unsigned long)addr); > > return (0); > > > > In the past when I've hit these types of problems, > I have found that using %#jx and casting to (uintmax_t) instead seemed to > work > consistently across different platforms, so you might want to do that here. > There are lots of examples in the tree of this pattern. > Any sort of cast will usually work, provided the casted-to type matches the format string. The main issue is when one tries to avoid a cast, in which case the fundamental type corresponding to the abstract type of the variable being printed can be different across different platforms. (Some sense is needed to ensure that the cast does not truncate the range of accessible values, of course, which is where [u]intmax_t comes in.) -Ben