Received: by 10.223.185.116 with SMTP id b49csp942320wrg; Fri, 16 Feb 2018 09:38:17 -0800 (PST) X-Google-Smtp-Source: AH8x2240qM2rYH+fJj225o+KJ6ZhJTkNbnAxOPgjwUTwpW+pQlQBZibcvynmc/HhBzsmMF3NGhuX X-Received: by 10.99.122.70 with SMTP id j6mr2715586pgn.17.1518802697601; Fri, 16 Feb 2018 09:38:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518802697; cv=none; d=google.com; s=arc-20160816; b=g/07Td69x1vDGN8YGm8MewyTdiAGi6gzHOsuHv8c/Srf70j6SJ2NHz+OPIywYVk8WS I/spNdupTvFq2Ziyf4i++dgrK6Y765TbUjk5dORav5DGFSxHbtr8af9uBdcfkACJmWOq dvEv9q8LfAdS9JuujD6MDqeSGiDhz98HcG57GrvLEvI3bAWzD57+5K3cXDEXqGSRZANj NLSz44kMkR/YZJ2cyibqA8k/ey3Arz3Alp+G8I5Ks9e+CE38zz445fdS95hL5SXlyAnS Ms8CuuiQSJb5c2ly1qZeR26iYl0hfsAtd+UqVqmoOPXTVmnBZQ0c+z6nwmBKTFKx9jQ8 d0ow== 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=mm1abQZTj3uAOFcfT9HPI+RJ6rCUA6dKy8zXBoWYdI0=; b=sN3V73G08pRvUUI/aviF5uNSgjKI7O32DtM3W2hTyWWT+QugHY1iCCHD777rMg85ty bWUrOYJO0OPEEjAj4ZkzJaAZH4djuoWIZsntrH6mulZ/ActfFA+zPvO+f5vdmSX0wYEm bi7s7dHw1O/EqGrNDV2CLOWizy8w64CAozN3pAOvfBaNg2NKxxn3uyvEd8rcMFHNto2U reCo586uh7pO3lrLXwmmkKsymOze/9+9GJUVXpjKfUFb1eYLfGbhn2R6lB262SGj6W66 4mdr3eKWRnj1tMu0zRDY4GTylZIdbg5zBSwq/BM9B8hmVN7IbriMH5I6rnbkH/rpF+VS cniQ== 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 v10-v6si4489610plo.820.2018.02.16.09.38.02; Fri, 16 Feb 2018 09:38:17 -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 S1163361AbeBOVdl (ORCPT + 99 others); Thu, 15 Feb 2018 16:33:41 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56808 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1162678AbeBOVdi (ORCPT ); Thu, 15 Feb 2018 16:33:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 844088424D; Thu, 15 Feb 2018 21:33:37 +0000 (UTC) Received: from localhost (ovpn-112-19.ams2.redhat.com [10.36.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E7D51004CA; Thu, 15 Feb 2018 21:33:31 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-kernel@vger.kernel.org Cc: slp@redhat.com, bhe@redhat.com, mst@redhat.com, somlo@cmu.edu, xiaolong.ye@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v15 04/11] fw_cfg: fix sparse warnings with fw_cfg_file Date: Thu, 15 Feb 2018 22:33:05 +0100 Message-Id: <20180215213312.29234-5-marcandre.lureau@redhat.com> In-Reply-To: <20180215213312.29234-1-marcandre.lureau@redhat.com> References: <20180215213312.29234-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.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 21:33:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 21:33:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 6164731a3c35..6ee12c9e079a 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -193,7 +193,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; }; @@ -257,17 +259,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); @@ -318,13 +320,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; } @@ -443,11 +445,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; @@ -457,7 +461,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); @@ -489,8 +493,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