mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-sh@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH RESEND] sh: sq: Use the bitmap API when applicable
Date: Tue, 18 Apr 2023 12:39:43 +0300	[thread overview]
Message-ID: <837e9f5e-ca8d-4c93-9a89-d7bdb9bb0240@kili.mountain> (raw)
In-Reply-To: <14788dbc-c2a6-4d1d-8ae3-1be53b0daf17@kili.mountain>

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

On Tue, Apr 18, 2023 at 10:30:01AM +0300, Dan Carpenter wrote:
> I have some unpublished Smatch stuff which tries to track "variable x
> is in terms of bit units or byte units etc."  I will try to make a
> static checker rule for this.

Attached.  It prints a warning like this:

drivers/net/ethernet/broadcom/cnic.c:667 cnic_init_id_tbl() warn: allocating units of longs instead of bytes 'test_var'

I'll test it out tonight.

regards,
dan carpenter

[-- Attachment #2: check_allocating_longs.c --]
[-- Type: text/x-csrc, Size: 1261 bytes --]

/*
 * Copyright 2023 Linaro Ltd.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
 */

#include "smatch.h"
#include "smatch_slist.h"

static int my_id;

static void match_allocation(struct expression *expr,
			     const char *name, struct symbol *sym,
			     struct allocation_info *info)
{
	struct smatch_state *units;
	char *str;

	units = get_units(info->total_size);
	if (!units || strcmp(units->name, "longs") != 0)
		return;

	str = expr_to_str(info->total_size);
	sm_warning("allocating units of longs instead of bytes '%s'", str);
	free_string(str);
}

void check_allocating_longs(int id)
{
	my_id = id;

	add_allocation_hook(&match_allocation);
}

  reply	other threads:[~2023-04-18  9:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 19:05 Christophe JAILLET
2023-04-16 19:33 ` John Paul Adrian Glaubitz
2023-04-17  6:51 ` Geert Uytterhoeven
2023-04-18  2:13 ` Rob Landley
2023-04-18  6:36 ` John Paul Adrian Glaubitz
2023-04-18  7:14   ` Geert Uytterhoeven
2023-04-18  7:18     ` John Paul Adrian Glaubitz
2023-04-18 18:05     ` Christophe JAILLET
2023-04-19 21:25       ` John Paul Adrian Glaubitz
2023-04-18  7:30   ` Dan Carpenter
2023-04-18  9:39     ` Dan Carpenter [this message]
2023-04-18  9:42       ` John Paul Adrian Glaubitz
2023-04-19  4:48       ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=837e9f5e-ca8d-4c93-9a89-d7bdb9bb0240@kili.mountain \
    --to=error27@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dalias@libc.org \
    --cc=geert@linux-m68k.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®