Received: by 10.223.185.116 with SMTP id b49csp739417wrg; Wed, 14 Feb 2018 06:20:20 -0800 (PST) X-Google-Smtp-Source: AH8x2262wzbLvzQc57UYjazGgTPTZe5QwElWl9EudzNArHWkdvRJbehEHMwBUSZFtWkMNIbLF5nV X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr4619154plk.212.1518618020440; Wed, 14 Feb 2018 06:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518618020; cv=none; d=google.com; s=arc-20160816; b=qhFjuQQsfyXi9vc/e6lawbeygpqyypqNpFWiqu5eHQl+Vy55yII+baWPi0URNQ4eUe e0J48+kR9qtEBdgrpad2PXFB8hH8vyUqv95mcGlFV8bGuXIMltpjTKGMLl+hW5PENPVD ydeiRDztCEj0OOFn5OMQ3DgDbyR4lGR/JUvM1DL2D6bWke4UHgjbjPjwPoIN4Va2UmqB 6RZGzealHeeZrNwl+HmXrxLJEhfmeRQ2IAW7VxztE+k6uI7jM2TzdKjPImwhx1jt3byh JP+hJ6AClc3nXcLc3j4CWZ/PHwi1yFXjegzX0ZNlZPvwg+pah8tFPtszA6xfqsF9ghH4 dhIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sEiDKlwRAKneYCNfYs+vlT/6275/Mr9yETlnVNrd7NY=; b=r/+Cm1uNyT4il4dZL1duLWOjDVvzCT/vFXGfunNwnyNb004OpJ6DsBy7N/M9bbgWqT MykHyhngzj/39ohZNmd5RgRAIr3WpOcutg7cnC9TUmMCuTwamHo0MP3qTF/PJggJEM22 20sWGlA+UVq0Oqq6TY64pnMo47RDy9AUyIKgwMy93lcDY0R29uQ9dWaYD3bl/NELJDmA vuPVtHuH27oUMqmHC6asozOC7lkfjImL6PkZZEbiTk1lvdXD1di1nprbSifYapMBTGlj rOoSFJu4y1bh69kxqelvLWyxpZdJB5Jcck79CySL6UkxN/NDg88rItMp2Q5Y6+klqXlx FDpg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b90-v6si7016720plb.429.2018.02.14.06.20.05; Wed, 14 Feb 2018 06:20:20 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030658AbeBNOTH (ORCPT + 99 others); Wed, 14 Feb 2018 09:19:07 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36130 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030288AbeBNOTE (ORCPT ); Wed, 14 Feb 2018 09:19:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D03C840201A0; Wed, 14 Feb 2018 14:19:03 +0000 (UTC) Received: from localhost (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BB4C1008394; Wed, 14 Feb 2018 14:18:57 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-kernel@vger.kernel.org Cc: bhe@redhat.com, slp@redhat.com, mst@redhat.com, somlo@cmu.edu, xiaolong.ye@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v14 4/9] fw_cfg: fix sparse warnings with fw_cfg_file Date: Wed, 14 Feb 2018 15:18:45 +0100 Message-Id: <20180214141850.4017-5-marcandre.lureau@redhat.com> In-Reply-To: <20180214141850.4017-1-marcandre.lureau@redhat.com> References: <20180214141850.4017-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 14 Feb 2018 14:19:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 14 Feb 2018 14:19:03 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Modify fw_cfg_sysfs_entry to store entry values, instead of reusing the restricted types. Fixes warnings such as: $ make C=1 CF=-D__CHECK_ENDIAN__ drivers/firmware/qemu_fw_cfg.o drivers/firmware/qemu_fw_cfg.c:491:29: warning: incorrect type in assignment (different base types) drivers/firmware/qemu_fw_cfg.c:491:29: expected restricted __be32 [usertype] size drivers/firmware/qemu_fw_cfg.c:491:29: got unsigned int drivers/firmware/qemu_fw_cfg.c:492:31: warning: incorrect type in assignment (different base types) drivers/firmware/qemu_fw_cfg.c:492:31: expected restricted __be16 [usertype] select drivers/firmware/qemu_fw_cfg.c:492:31: got int Signed-off-by: Marc-André Lureau --- drivers/firmware/qemu_fw_cfg.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index 85e693287d87..8ad19086e5c5 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -192,7 +192,9 @@ static const struct { /* fw_cfg_sysfs_entry type */ struct fw_cfg_sysfs_entry { struct kobject kobj; - struct fw_cfg_file f; + u32 size; + u16 select; + char name[FW_CFG_MAX_FILE_PATH]; struct list_head list; }; @@ -256,17 +258,17 @@ struct fw_cfg_sysfs_attribute fw_cfg_sysfs_attr_##_attr = { \ static ssize_t fw_cfg_sysfs_show_size(struct fw_cfg_sysfs_entry *e, char *buf) { - return sprintf(buf, "%u\n", e->f.size); + return sprintf(buf, "%u\n", e->size); } static ssize_t fw_cfg_sysfs_show_key(struct fw_cfg_sysfs_entry *e, char *buf) { - return sprintf(buf, "%u\n", e->f.select); + return sprintf(buf, "%u\n", e->select); } static ssize_t fw_cfg_sysfs_show_name(struct fw_cfg_sysfs_entry *e, char *buf) { - return sprintf(buf, "%s\n", e->f.name); + return sprintf(buf, "%s\n", e->name); } static FW_CFG_SYSFS_ATTR(size); @@ -317,13 +319,13 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj, { struct fw_cfg_sysfs_entry *entry = to_entry(kobj); - if (pos > entry->f.size) + if (pos > entry->size) return -EINVAL; - if (count > entry->f.size - pos) - count = entry->f.size - pos; + if (count > entry->size - pos) + count = entry->size - pos; - fw_cfg_read_blob(entry->f.select, buf, pos, count); + fw_cfg_read_blob(entry->select, buf, pos, count); return count; } @@ -442,11 +444,13 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) return -ENOMEM; /* set file entry information */ - memcpy(&entry->f, f, sizeof(struct fw_cfg_file)); + entry->size = be32_to_cpu(f->size); + entry->select = be16_to_cpu(f->select); + memcpy(entry->name, f->name, FW_CFG_MAX_FILE_PATH); /* register entry under "/sys/firmware/qemu_fw_cfg/by_key/" */ err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype, - fw_cfg_sel_ko, "%d", entry->f.select); + fw_cfg_sel_ko, "%d", entry->select); if (err) goto err_register; @@ -456,7 +460,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) goto err_add_raw; /* try adding "/sys/firmware/qemu_fw_cfg/by_name/" symlink */ - fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->f.name); + fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->name); /* success, add entry to global cache */ fw_cfg_sysfs_cache_enlist(entry); @@ -488,8 +492,6 @@ static int fw_cfg_register_dir_entries(void) fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(count), dir_size); for (i = 0; i < count; i++) { - dir[i].size = be32_to_cpu(dir[i].size); - dir[i].select = be16_to_cpu(dir[i].select); ret = fw_cfg_register_file(&dir[i]); if (ret) break; -- 2.16.1.73.g5832b7e9f2