Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3983457ybg; Mon, 28 Oct 2019 23:55:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNIUhdlzKykgV+1Di3w+vcSLzJjmrWavdp9rjEHfIw2DQLEWIZWSG3PGi+tXMZs76BJunV X-Received: by 2002:a17:906:ccc7:: with SMTP id ot7mr1631613ejb.326.1572332131925; Mon, 28 Oct 2019 23:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572332131; cv=none; d=google.com; s=arc-20160816; b=iiqRGc3PHTel0xibduVFwi0TwDQ86ZHJcJ4n1RAUufOUyAkyqn4dfU5Lc3r5hi0O1n V4VzATBr193cibTYYBe8NiO8Sq/Ma76CrCnQF+1n08IUQGy3lbi38YoxzSL2bASoywc9 VJ+K8vhweqPTdk16aNMG4Lhs4IlVQL3lQmuzJQZmtd+xrhpmPWVSfXf6YYKjZ+WE270p 2Ze5X/Se5drC8FMrEsCzxlEaaesMOffH0WFcs/h7bAhz4H/sH3c4D60J7hKxVne/d060 tdi8oQaNkHg2BzqbJJVN4Uvz5g4BpiHPFlEbELZiQOZDtElsOJ2UzfIAgAG7mitNYwM3 fRNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=A2jEsBOs5Fgq1k1SUjS53cvLXGYRrdoo13cMo5AIHyk=; b=XYhONrF5SNJxbXVQwnzmiC71ps0PPB3t6hiYtu3J+qfiQtSepjGr2zNufyGTvE87gs xE5IA59ZMRncwId+Ta881KDVS133hFJfRWfRSJV/wF2pyoV9TYZARGq1lDNI7u76QwY7 4nOO/CY1xKZIZMRekiMh6cSqEagRsIQf/c6Ni3qapi59HSfGoXSFB4wYkaHrfgIFkGtG FoJNdMOBFhpFo5GKEzETxsMbZAiQ1PH95R5gsD/JAe4ruRQUCzEK0BmKqnuGzO+Gxu3l /Fz8+fM3E2uqtvOcICAoAPneDYhQYT+hPOx2jPleHMWczyZCk23uYZETgwRTdKgCNMfJ f1Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="i/IpsRc5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mh11si7172622ejb.172.2019.10.28.23.55.08; Mon, 28 Oct 2019 23:55:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="i/IpsRc5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729953AbfJ1WtT (ORCPT + 99 others); Mon, 28 Oct 2019 18:49:19 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:38416 "EHLO mail-wr1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfJ1WtT (ORCPT ); Mon, 28 Oct 2019 18:49:19 -0400 Received: by mail-wr1-f49.google.com with SMTP id v9so11592944wrq.5; Mon, 28 Oct 2019 15:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=A2jEsBOs5Fgq1k1SUjS53cvLXGYRrdoo13cMo5AIHyk=; b=i/IpsRc5S8qtvd4Hd2Jajl2muQJLkQ9Z8YMjvk6JZSa68F2SqLABksVza3TMROQk1l /4QBiNY1iKt19N2BdTTsYSNeafJcDTRO2E4QtC+5aruM0hW4mtc5ftJT2S5L8GFlPVO6 YKMW91bU1FKH8m7wjlo0qMRlZEa5yscXWnOT5TtkxhV6uvyZw6int+SGf31E8CCgtgK/ +PnCW1FPhrNJnrlSQzaig+42FGFhZKigWWA1U5aJGoTzmzNKFNpQRyc3dJn4Eh6uVJle kVA2eUWPyplVvIfzyavyLQm4lpmFVVkZvdSAmIfbVaktYI6/5+jFr0jbVFruWSb1RxEh +Lzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=A2jEsBOs5Fgq1k1SUjS53cvLXGYRrdoo13cMo5AIHyk=; b=DOrr8kb/MjohnRRbaqHcEszxolytGIe8Dgei8oQL1LUrA3Nff//Mxuf5qNwQxA0nBS xWxojUwDCOKhrHjhWThGDZTEr/kfdW8XkZGc/5YTIk5nWlSq0gyMC6zurDNAwoabSCXC U3l27oaFPvOs65VVKUg8CcEx7mvB9JTDFQ4NQTSFEhbfFJyXYrBHPyj/xaA21wELXaz+ QMIa1AsxYTtH20yqWcBcPQ+12sCEP8ZnKHJZKXEl+ISnczRuO9PPgwD1K1rpFQ/9UAJk 0+rqcdSAS847FnL6IxOra+VK9IsNCRrf1HaOWO7BWSLspaj4yPeekfr6KS0J8kUw/o/x ZxTA== X-Gm-Message-State: APjAAAUld68BVZGsIO9kwDqZGaTytTsHKb6Y7shLIUpugWCzg05ViHpe x3Ky8nPzqOFpaLpa5JTXKaIA5eXI X-Received: by 2002:adf:f44e:: with SMTP id f14mr16228477wrp.56.1572302957156; Mon, 28 Oct 2019 15:49:17 -0700 (PDT) Received: from desk.local ([2a02:a03f:40ac:ce00:6dcd:e18f:2cd1:7611]) by smtp.gmail.com with ESMTPSA id u7sm14094078wre.59.2019.10.28.15.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 15:49:16 -0700 (PDT) Date: Mon, 28 Oct 2019 23:49:15 +0100 From: Luc Van Oostenryck To: Rasmus Villemoes Cc: Dan Carpenter , linux-sparse@vger.kernel.org, LKML Subject: Re: detecting misuse of of_get_property Message-ID: <20191028224914.enpqjkcvbxyeexnl@desk.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 28, 2019 at 08:32:42PM +0100, Rasmus Villemoes wrote: > Hi, > > I just spent some time trying to convert some so far PPC-only drivers to > be more generic. One of the things I had to do was convert stuff like > > u32 *val = of_get_property(np, "bla", NULL); > do_stuff_with(*val); > > with > > of_property_read_u32(np, "bla", &val); > do_stuff_with(val); > > (error checking omitted for simplicity). The problem is that > of_get_property() just returns void*. When the property is just a > string, there's no problem interpreting that as a char*. But when the > property is a number of array of numbers, I'd like some way to flag > casting it to u32* as an error - if you cast it to a (pointer to integer > type wider than char), it must be to a __be32*. Is there some way > sparse/smatch could help find such cases? If I understand you correctly, you would need a kind of 'soft' bitwise pointer? I guess it shouldn't be too hard to add a new flag which would allow cast of bitwise pointers to pointers to char/void (see at end of evaluate.c:evaluate_cast()). Note: casts from bitwise pointer to void* are already allowed. -- Luc