From owner-svn-src-head@freebsd.org Mon Jan 30 04:51:39 2017 Return-Path: Delivered-To: svn-src-head@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 CA94DCC7565 for ; Mon, 30 Jan 2017 04:51:39 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-it0-x242.google.com (mail-it0-x242.google.com [IPv6:2607:f8b0:4001:c0b::242]) (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 966461B39 for ; Mon, 30 Jan 2017 04:51:39 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-it0-x242.google.com with SMTP id o185so14331360itb.1 for ; Sun, 29 Jan 2017 20:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:message-id:from:to:in-reply-to:content-transfer-encoding :mime-version:subject:date:references; bh=6ACelhoQDh0RbYsIJHoPJVeQsgIFBmwr5qm1hMAv9es=; b=OwdHTbnDt8OBWkSF9VzgkJEUZK5+iwlsfIJYFVtlmTbBmEO88KNim3pqZ+yUIIUMIl 1wj/yilFlYBd8zKYjxvyhi2ivCt3AL98t2FaiT/fPbdATuUFXrIKneYMkM6LgrLlaAxx bb9JQqvXt+r0G/vKno70fJBDbdySTVxtawUh9AvzgxGWP2uTb9Z7j5JaGCjcYlnp6wOT Y4nuHFj7cUQ+pywEuyAq5ko62NtBNgbJFjGeonWAWoAa03nAMVKz+80BbklhssEmNL2Q DJq9wTBs5ZmGKT5tSMJFRRHjcNP4JjKrgZ+/LVWRkUrEwPai7Cc26jDJXiT/eTM8BOnD BsSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:message-id:from:to:in-reply-to :content-transfer-encoding:mime-version:subject:date:references; bh=6ACelhoQDh0RbYsIJHoPJVeQsgIFBmwr5qm1hMAv9es=; b=WUWVqIRoXscMWUZgVsNdyfPvyo7yo6g9LBRdBwzrPtDpZoNy9OVaDgHrC5B5BiYs6Q 5sih1L2Xmba5Mcj7jJwCPTB9c1LY3KLjO0WhbiJhtq8QtuuJ7P0bgCuIwW8s3S60OPdT YXA+fRh8edthR6fvFmflsWLkwoPdqdNA3k7kjdSGQmMSfY0J/ZDJdu2pKW4RBukXO4XV 5iP84WGPjQlQwvjPXrEJojNMbKFJYVQkxM7fokbAG0a3OjQcxfaxyqlyGUquQH3Mcmpb V5mUwDcZqglVozzzEd0EGBUdLf3Yo/+lSnQg35ULoXv0lYVw4sorwAPYXair1J4+R+Uq Ft1w== X-Gm-Message-State: AIkVDXK5+nKASsQGzlYCe5XXD6e4MRdwFfVfjfM2iLGzJYelBX2+4BNfUsyC/fAM900PJQ== X-Received: by 10.36.181.87 with SMTP id j23mr14865323iti.68.1485751898805; Sun, 29 Jan 2017 20:51:38 -0800 (PST) Received: from blackstar.knownspace (50-80-150-234.client.mchsi.com. [50.80.150.234]) by smtp.gmail.com with ESMTPSA id n134sm5821418itg.19.2017.01.29.20.51.37 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 29 Jan 2017 20:51:38 -0800 (PST) Cc: svn-src-head@freebsd.org Message-Id: From: Justin Hibbits To: Mark Millard In-Reply-To: <588CB781-A470-4101-8108-ADAD34525422@dsl-only.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: svn commit: r312977 - head/sys/dev/adb Date: Sun, 29 Jan 2017 22:51:36 -0600 References: <588CB781-A470-4101-8108-ADAD34525422@dsl-only.net> X-Mailer: Apple Mail (2.936) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 30 Jan 2017 04:51:39 -0000 Hi Mark, On Jan 29, 2017, at 9:42 PM, Mark Millard wrote: >> Author: jhibbits >> Date: Mon Jan 30 02:32:33 2017 >> New Revision: 312977 >> URL: >> https://svnweb.freebsd.org/changeset/base/312977 >> >> >> Log: >> Force the setting of bit 7 in the sysmouse packet byte 1 to be >> unsigned. >> >> Clang complains about the shift of (1 << 7) into a int8_t changing >> the value: >> >> warning: implicit conversion from 'int' to 'int8_t' (aka 'signed >> char') changes >> value from 128 to -128 [-Wconstant-conversion] >> >> Squash this warning by forcing clang to see it as an unsigned bit. >> >> This seems odd, given that it's still a conversion of 128->-128, >> but I'm >> guessing the explicit unsigned attribute notifies clang that sign >> really doesn't >> matter in this case. > > [The following is based just on the C standard, not POSIX > or other standards that may also be involved from FreeBSD's > point of view.] > > An FYI/explanation of sorts. . . > > In the C11 standard (e.g., since I have it handy) having the > new type be signed has the rule for signed and unsigned integer > implicit conversions between the types: > > (After the cases of value-representable-so-value-is-unchanged > and new-type-is-unsigned, quoting:) > >> Otherwise, the new type is signed and the value cannot be represented >> in it; either the result is implementation-defined or an >> implementation-defined signal is raised. > > So while 1U use may make the compiler(s) tested be quiet it still > leaves > the code in implementation-defined territory where different starting > types for the same value are allowed to have different results. But > they are not required to and compiler releases could change the > classification --and if there are messages from the compiler or not. > Bit patterns need not be preserved for the sign-bit and/or > value-carrying bits in the new type vs. the old type. > > (By contrast a new type being unsigned is defined with a > mathematically > specific/unique result and so a specific bit pattern for the > value-carrying bits, ignoring trap representations and other pad bits > if they exist.) Thanks for the explanation. I had a feeling I was in undefined and/or implementation defined behavior with this, and was surprised that it squashed the warning with such a trivial change. I think we're safe here, though, since the PowerPC ABI and Power ABI are well defined. - Justin