From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32E01C47089 for ; Thu, 27 May 2021 15:27:31 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D36B960FDC for ; Thu, 27 May 2021 15:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D36B960FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1lmHuq-0000OB-Tt; Thu, 27 May 2021 11:27:20 -0400 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1lmHuo-0000O2-62 for kernelnewbies@kernelnewbies.org; Thu, 27 May 2021 11:27:18 -0400 Received: by mail-yb1-xb34.google.com with SMTP id y2so1166498ybq.13 for ; Thu, 27 May 2021 08:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W4qLQonX+DdveyOb9hdu28nVTfRO8+UtjH08OruE4n0=; b=MKk5QAHvKHefMDUiBAKmeziQt8zjECwSyuUenqcGdADw7FA6euMe28oYvCzU3dRaH9 FRs6CMbTdKxxS5Lipx3dwB69mejolFZiVROH7YwSqP7DeVUX99u9a07APvg4NQJG191H xvw/qBnP7fq+3Jy4NZ8D6zJQIbXDvC5NMPh8hc4kLgqCAVHIoowXd7Oig2L3tQQN3JHb Jn1Zd8g0Ph+Xj8Bf7KOxikqrdVy1o9CecgsiQyCkK1OX7HEiuHcci1N6kq5tEHImdLcL aOxGyFsA/XCrjS0Bvv/xsmF3C/Uy8Dda+I9OvoKMJ5mDfr2JP0059VSRATJ2v+N4LCjW OXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W4qLQonX+DdveyOb9hdu28nVTfRO8+UtjH08OruE4n0=; b=EpeBiQ5pz0G3FeW19g+Dla/jUBTjUQyrfWCx84r6gCj+1wYiqMK/tgFp9WxiKw34WU tdmZTUH9C39FzE/czSUtGxdbK19djolRD52oot/0D83xfx15zbfDoxWL3ZOhWDehLHRC Fp3+8hx8F3Y/wH5BLn0UyWq+IIxhYOwfrHcZJKXclllyrINA/I72TnOSaTJ4HsaVKsFD fUwh2MrfW17og7gg0Q6oInQI+xN3d1G8h+oIj8dweeOJQFW4lsOL2TJ5wdYyZPaYRZY1 mhArcKNNFWdPO1uLxuML6Cd8WTdAj865RdmYdUAeO86PK67Zoc1nHPcqyECwJeFAlLSd sImg== X-Gm-Message-State: AOAM530u8N3Pl752NkYDAhNbGOtHkEStHqepYsiv1T2WSfLcSoM7lkbi gZN43LxRrH50WoSZnR2g5VNyenqLwn0EMez8ETI= X-Google-Smtp-Source: ABdhPJzdfz4ixvR+ENwTMtn/DX5AU4cWYw1OoQVZSMU63iYZv3h/6dkJ82cN3epEQi+vM4wPsI6Hd0DGiIakxVBbxe4= X-Received: by 2002:a5b:90d:: with SMTP id a13mr5772176ybq.151.1622129237262; Thu, 27 May 2021 08:27:17 -0700 (PDT) MIME-Version: 1.0 References: <20210527151443.GA138263@hyeyoo> In-Reply-To: <20210527151443.GA138263@hyeyoo> From: Lukas Bulwahn Date: Thu, 27 May 2021 17:27:06 +0200 Message-ID: Subject: Re: Performing pointer arithmetic on a null pointer? To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Thu, May 27, 2021 at 5:15 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > Hello, I was compiling kernel with make CC=clang-10 W=1 -s > > there are some places that compiler complains about > pointer arithmetic like below.it says it's undefined behavior. > > is it just OK to use UBs like this (I hope it's not), > or am I missing something? > > fs/kernfs/file.c:128:15: warning: performing pointer arithmetic on > a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > return NULL + !*ppos; > > Hyeonggon, there is a patch series from Arnd Bergmann, a well-known kernel developer and janitor, hanging around here: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=warnings-5.10-2 It includes a patch to address this issue: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/commit/?h=warnings-5.10-2&id=cda293a8ee8a2bc763c33828cbc9ff21af987d45 The patch title and commit message indicates that this was submitted in multiple versions to the mailing list. You can find more on its progress on the mailing list here: https://lore.kernel.org/lkml/?q=seq_file%3A+fix+clang+warning+for+NULL+pointer+arithmetic It seems that it has not landed in linux-next yet, though: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=grep&q=seq_file%3A+fix+clang+warning+for+NULL+pointer+arithmetic The commit and discussion around it will give you much more technical details on the issue and its resolution. I hope this helps. Lukas _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies