Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp201286pxb; Wed, 14 Apr 2021 13:03:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr4YgG/ttdirQFX+dVFjjTOJ8A51ujxkx24h3IvuZQxxBuL8AaATWfWEi1/99BOs2RPfif X-Received: by 2002:a17:906:8a6e:: with SMTP id hy14mr580131ejc.356.1618430588481; Wed, 14 Apr 2021 13:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618430588; cv=none; d=google.com; s=arc-20160816; b=V6iWpgBgs0BYEhh5IUYccGHfM4v1h4bK1FZC1XDM1P3UUJOUjrisyVn3MgJYr44Qtu CMsij6HGq5rbAqaTelb+KyoUoRa/czhkiPRRMetBPv/jYCXxjP+KLHl6paIGO/Cu7d5N Svz++lG7cMcc5V5UX1uBK+2XiTV8uKA5c2PxuHYXzXuN7/Sk3NkyY8t3WWpx3uC28zWe eCPcatgd/mS+nUIjNEfEEXv/+PSVMpZ1fR7zmWp8zdb8jhUyeIIvw7h7axCI7gzHdUjZ LS0DLsMtcyCvk+RjyFpDtd7jFRaKdjv7smmUDU20kevb7T8Ce57y4xN/F+6wJXPHbuNV HWVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bu4zAf2jISjqqt34xkjaMJooW0UMSg6yw1pdyWLERQ4=; b=NTQRX/362/68SWtE4zsy2pJEJYFagWMkz1QrCJNAH7eNdexIpSLL9cU0Zc76UoG9gR lYZZE5TD/nvgx3z1l1xN2QAeQeMQzLwp3k5h31KzwAttXhPMP0z2FVrp3S+xom3MqOO5 xG/2Qmlw++zIYWz8hZB0zTVtNKJHUDv3I8TuPc+j6ewMNnvyXxLgqAYx6PdqifVtVtj6 kO3ZD8/xuknxkaWBXSJlOV8KdBzkeAMA6H+TQXPXNUMHpjWa/KzMpoqSBHzIZv/DTCs/ 0tXaW6cse9NEb+f/Hsc8e0d7nKhM5Jfyezs/MxF42r5jp1yC82BuBxWTiFnyUCWhnjy7 PWoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rvw2CCqY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id e6si496351edz.445.2021.04.14.13.02.45; Wed, 14 Apr 2021 13:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rvw2CCqY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231715AbhDNHlI (ORCPT + 99 others); Wed, 14 Apr 2021 03:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbhDNHlE (ORCPT ); Wed, 14 Apr 2021 03:41:04 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C87F9C061574 for ; Wed, 14 Apr 2021 00:40:40 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so9990559wmj.2 for ; Wed, 14 Apr 2021 00:40:40 -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=bu4zAf2jISjqqt34xkjaMJooW0UMSg6yw1pdyWLERQ4=; b=Rvw2CCqYnzRr0eG8NuAMtT86cq+1bEzMrsRbG6hbIXN7uJKWc0euT2+JOMt8ILTr4L Cd3eZiNGMOpl+4l7WqogGNJpv2074iCeVEU8cDxPdvxO+x1Y7VPk1VRy2SlZXVk9V2yi iHtpYqRgEPipjDh8y7qSza7EmcZd0CM6Im/M0JmEutemDYt6Dxv1gnYDLAbHs5jO19Gt SdmPcITVG2L0ZoynGmwkpTrX8FqsTIrAvHYhZt45oAG7Eb2RSUSl2qjj38bYYqsDCAi9 8whp+sfHixF3ajigPqaK4BjtJfJS4N+avSx+hEXmeRPSsBOYn/NGAVl/ZxN8c2vhrAJ/ YKsw== 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=bu4zAf2jISjqqt34xkjaMJooW0UMSg6yw1pdyWLERQ4=; b=Hu7B20H6PPaWcRHkMT9L7fNrJpZirOr7PmR+5EOTW6TxHqMm/sn+qvfcCkI6oWi51T syfrJzB1zT8gmu94Che9kTBkZQ8Wq7s/O56nwv8OQOGQSVWIfyhYP0+9tVx0Yqyp8Ahm +LbM++ZMXFthG9XycQygL+9j3MJjpD41pjOzCgPGTDKvSIlnAp66koO9ZVIqnh+iR3AV E7gcpoyjlN7g2HZVuwmm54fCLa/ojKbOm6bME2pRJgQrpOAfMY3rItbJ1/pWxkHRI5Io QfUqcSwYUGrZjf5WVTEyAauItHLZxE3XuibN8cN+TefrkfOEskqUH83Mtz4qACK94480 OI+g== X-Gm-Message-State: AOAM530pKFjSi+l1Am5Vj3UAT6OdfcIdmOfeqG0eV17xy5koADDcyghW SvyCsh/J+IOnPPE+pp46Tj4= X-Received: by 2002:a1c:1f92:: with SMTP id f140mr1585117wmf.108.1618386039509; Wed, 14 Apr 2021 00:40:39 -0700 (PDT) Received: from agape.jhs ([5.171.25.35]) by smtp.gmail.com with ESMTPSA id s8sm22226460wrn.97.2021.04.14.00.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 00:40:39 -0700 (PDT) Date: Wed, 14 Apr 2021 09:40:36 +0200 From: Fabio Aiuto To: Dan Carpenter Cc: "Fabio M. De Francesco" , Matthew Wilcox , Julia Lawall , outreachy-kernel@googlegroups.com, Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [Outreachy kernel] [PATCH] :staging: rtl8723bs: Remove useless led_blink_hdl() Message-ID: <20210414074035.GA1880@agape.jhs> References: <20210413155908.8691-1-fmdefrancesco@gmail.com> <7008359.Jy8utYDuns@linux.local> <20210413194844.GR2531743@casper.infradead.org> <3505455.GpAHCVcAZI@linux.local> <20210414052150.GO6021@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210414052150.GO6021@kadam> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14, 2021 at 08:21:50AM +0300, Dan Carpenter wrote: > On Tue, Apr 13, 2021 at 10:08:32PM +0200, Fabio M. De Francesco wrote: > > On Tuesday, April 13, 2021 9:48:44 PM CEST Matthew Wilcox wrote: > > > On Tue, Apr 13, 2021 at 09:45:03PM +0200, Fabio M. De Francesco wrote: > > > > 1) The driver doesn't call that function from anywhere else than the > > > > macro. 2) You have explained that the macro add its symbol to a slot > > > > in an array that would shift all the subsequent elements down if that > > > > macro is not used exactly in the line where it is. > > > > 3) Dan Carpenter said that that array is full of null functions (or > > > > empty slots?). > > > > > > > > Unless that function is called anonymously dereferencing its address > > > > from the position it occupies in the array, I'm not able to see what > > > > else means can any caller use. > > > > > > > > I know I have much less experience than you with C: what can go wrong? > > > > > > Here's where the driver calls that function: > > > > > > $ git grep wlancmds drivers/staging/rtl8723bs/ > > > drivers/staging/rtl8723bs/core/rtw_cmd.c:static struct cmd_hdl wlancmds[] > > > = { drivers/staging/rtl8723bs/core/rtw_cmd.c: if > > > (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { > > > drivers/staging/rtl8723bs/core/rtw_cmd.c: cmd_hdl > > > = wlancmds[pcmd->cmdcode].h2cfuns; > > > > > OK, I had imagined an anonymous call from its location in the array (as I > > wrote in the last phrase of my message). However, I thought that it could > > have been an improbable possibility, not a real one. > > > > Linux uses a lot of interesting ideas that newcomers like me should learn. > > Things here are trickier than they appear at first sight. > > One trick would be to build the Smatch cross function database. > > https://www.spinics.net/lists/smatch/msg00568.html > > Then you could do: > > $ ~/path/to/smatch_data/db/smdb.py led_blink_hdl > file | caller | function | type | parameter | key | value | > drivers/staging/rtl8723bs/core/rtw_cmd.c | rtw_cmd_thread | rtw_cmd_thread ptr cmd_hdl | INTERNAL | -1 | | uchar(*)(struct adapter*, uchar*) > drivers/staging/rtl8188eu/core/rtw_cmd.c | rtw_cmd_thread | rtw_cmd_thread ptr cmd_hdl | INTERNAL | -1 | | uchar(*)(struct adapter*, uchar*) > drivers/staging/rtl8188eu/core/rtw_cmd.c | rtw_cmd_thread | rtw_cmd_thread ptr cmd_hdl | BUF_SIZE | 1 | pbuf | 1,4,6,8,12,14,16,19-20,23-24,48,740,884,892,900,960 > > > Which says that led_blink_hdl() is called as a function pointer called > "cmd_hdl" from rtw_cmd_thread(). > > Hm... It says it can be called from either rtw_cmd_thread() function > (the rtl8723bs or rtl8188eu version) which is not ideal. But also > basically harmless so whatever... > > regards, > dan carpenter > very powerful tool. I tried this: fabio@agape:~/src/git/kernels/staging$ ~/src/git/smatch/smatch_data/db/smdb.py led_blink_hdl Traceback (most recent call last): File "/home/fabio/src/git/smatch/smatch_data/db/smdb.py", line 725, in print_caller_info("", func) File "/home/fabio/src/git/smatch/smatch_data/db/smdb.py", line 366, in print_caller_info ptrs = get_function_pointers(func) File "/home/fabio/src/git/smatch/smatch_data/db/smdb.py", line 53, in get_function_pointers get_function_pointers_helper(func) File "/home/fabio/src/git/smatch/smatch_data/db/smdb.py", line 38, in get_function_pointers_helper cur.execute("select distinct ptr from function_ptr where function = '%s';" %(func)) sqlite3.OperationalError: no such table: function_ptr I run smatch version 1.71 on Debian Buster machine what's happened? thanks in advance, fabio