From patchwork Tue Jul 10 07:00:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cheng Renquan X-Patchwork-Id: 1176161 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D086DFF34 for ; Tue, 10 Jul 2012 07:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752809Ab2GJHAe (ORCPT ); Tue, 10 Jul 2012 03:00:34 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:48060 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752152Ab2GJHAd convert rfc822-to-8bit (ORCPT ); Tue, 10 Jul 2012 03:00:33 -0400 Received: by wibhm11 with SMTP id hm11so4179223wib.1 for ; Tue, 10 Jul 2012 00:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=75/YogxOx+F1OSJf2IEpohoEoR/nkxt+t5twoV2zlv0=; b=AaV20CpZpZWIhW8F5AQvORz0+U3V1I3C7AB88SnodSDstKsCN/9UZo9wAa8LMBZhub YU85ppR2fS5CED1NnM4U7HaPFi0OpuYNJ8H+msiqGVUVe69GibizrjZf5WD2Ip/zg7DO yA6vKjAQSdHRGzF3ESyubobs83PLILR36yirleNIdbZCcWY1Yl32Ojro9u0i/I3COABV MyD6bLigwYEAfi/Y9HSTuk9ANbTbhwWth7X2pDcv+0OnxTE4Fi0RBbczg57I3KD4Inw1 hKYXQDAixFVozheir9Q3Ow2aPGBIpcEMx4s6aERkkJn45mM39TrpGRrsr9NQqoqBR3aH nnnA== MIME-Version: 1.0 Received: by 10.216.193.166 with SMTP id k38mr16902498wen.200.1341903631607; Tue, 10 Jul 2012 00:00:31 -0700 (PDT) Received: by 10.216.7.132 with HTTP; Tue, 10 Jul 2012 00:00:31 -0700 (PDT) Date: Tue, 10 Jul 2012 00:00:31 -0700 Message-ID: Subject: acpi: remove unused LIST_HEAD(acpi_device_list) && more static analysis From: cheng renquan To: Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org I just came across this file and found this LIST_HEAD(acpi_device_list) was referred in early days before 2.6.11 but not in use nowadays, ^1da177e drivers/acpi/scan.c (Linus Torvalds 2005-04-16 15:20:36 -0700 31) static LIST_HEAD(acpi_device_list); it is expanded to this line of referring itself form so gcc won't emit a warning, static struct list_head acpi_device_list = { &(acpi_device_list), &(acpi_device_list) }; If change to this line of just declaration then it could really cause a gcc warning: +static struct list_head acpi_device_list; drivers/acpi/scan.c:31:25: warning: ‘acpi_device_list’ defined but not used [-Wunused-variable] Now I'm guessing the kernel code may have more such dead variables, at least we could do a globally search to see there are more LIST_HEAD declaration without a 2nd reference; but does anyone have done this before or know any existing tools / such static analysis approaches? Thanks, === $ git diff HEAD -- drivers/acpi/scan.c diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 85cbfdc..7d26ae0 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -28,7 +28,7 @@ extern struct acpi_device *acpi_root; static const char *dummy_hid = "device"; -static LIST_HEAD(acpi_device_list); static LIST_HEAD(acpi_bus_id_list); DEFINE_MUTEX(acpi_device_lock); LIST_HEAD(acpi_wakeup_device_list);