Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757080AbdLXD2k (ORCPT ); Sat, 23 Dec 2017 22:28:40 -0500 Received: from mail-oi0-f51.google.com ([209.85.218.51]:39467 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbdLXD2j (ORCPT ); Sat, 23 Dec 2017 22:28:39 -0500 X-Google-Smtp-Source: ACJfBougXZ6MauRNNTbSO2F4bs4zQsIx0AaG7CJ0oPSPQgSta/HeAzVWioRw2CjyDiodVv6OoTTugjEeEexeQLY1rO0= MIME-Version: 1.0 In-Reply-To: <20171224032437.GB5273@bombadil.infradead.org> References: <1514082821-24256-1-git-send-email-nick.desaulniers@gmail.com> <20171224032437.GB5273@bombadil.infradead.org> From: Nick Desaulniers Date: Sat, 23 Dec 2017 22:28:37 -0500 Message-ID: Subject: Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted To: Matthew Wilcox Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , linux-mm@kvack.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 920 Lines: 29 On Sat, Dec 23, 2017 at 10:24 PM, Matthew Wilcox wrote: > On Sat, Dec 23, 2017 at 09:33:40PM -0500, Nick Desaulniers wrote: >> Fixes warnings about shifting unsigned literals being undefined >> behavior. > > Do you mean signed literals? A sorry, s/unsigned/negative signed/g. The warning is: mm/zsmalloc.c:1059:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value] link->next = -1 << OBJ_TAG_BITS; ~~ ^ > >> */ >> - link->next = -1 << OBJ_TAG_BITS; >> + link->next = -1U << OBJ_TAG_BITS; >> } > > I don't understand what -1U means. Seems like a contradiction in terms, > a negative unsigned number. Is this supposed to be ~0U? $ ag \\-1U[^L] The code base is full of that literal. I think of it as: (unsigned) -1