Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eROzM-0000Le-Va for mharc-grub-devel@gnu.org; Tue, 19 Dec 2017 15:59:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eROzK-0000Ks-4F for grub-devel@gnu.org; Tue, 19 Dec 2017 15:59:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eROzH-0001qQ-Iz for grub-devel@gnu.org; Tue, 19 Dec 2017 15:59:46 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:59880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eROzH-0001p5-7x for grub-devel@gnu.org; Tue, 19 Dec 2017 15:59:43 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBJKubfp096337; Tue, 19 Dec 2017 20:59:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2017-10-26; bh=xc5X+bIgayp4aJr1kHkXImf2h/1TbUAanXVtBLcoSq4=; b=Wzp/n1IiQ3Ln2BhJslnXniE3kQ9rmHi9kSUjqIPZGISZjU9ZZu5MFZGa5u5FWDM6L3Lo K2V5wwl/Fhwdyb8r3pZl4CMvkoDZK8UPEo0mhFj3QWgUQr/b8Wrj4oLjGiqLItkucvB1 QaoG7nZjSQnnl+q/KuaWKG0UoWdXfSzHICz2d0BDmLQxeY1xuxKdgKnm6NMsvUJw2bR/ RYpSuEyJmBCRf+DlKUDu1nPmhONa4+ev/MWJoLQBk4QSLkbYwRw9JiJRxPpN1bokIgH0 Dsvlbf3jdCdXAPr5j3AcB4kfRQdBg1Iy3W7VxunZm5lQ4YjEcedWEQCCgHijjhV1WTdz 0w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2ey9v20c1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Dec 2017 20:59:34 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vBJKuwc7019694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Dec 2017 20:56:58 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vBJKuvtm020686; Tue, 19 Dec 2017 20:56:58 GMT Received: from olila.local.net-space.pl (/10.175.173.126) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Dec 2017 12:56:57 -0800 Date: Tue, 19 Dec 2017 21:56:53 +0100 From: Daniel Kiper To: Eric Snowberg Cc: grub-devel@gnu.org, phcoder@gmail.com Subject: Re: [PATCH] sparc64: fix OF path names for sun4v systems Message-ID: <20171219205653.GJ4531@olila.local.net-space.pl> References: <1512604410-69771-1-git-send-email-eric.snowberg@oracle.com> <20171218152225.GY4531@olila.local.net-space.pl> <66985316-E572-4572-AB22-5DB1617D7B3E@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <66985316-E572-4572-AB22-5DB1617D7B3E@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8750 signatures=668650 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712190297 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2120.oracle.com id vBJKubfp096337 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Dec 2017 20:59:47 -0000 On Mon, Dec 18, 2017 at 02:30:51PM -0700, Eric Snowberg wrote: > > On Dec 18, 2017, at 8:22 AM, Daniel Kiper w= rote: > > On Wed, Dec 06, 2017 at 03:53:30PM -0800, Eric Snowberg wrote: > >> Fix the Open Firmware (OF) path property for sun4v SPARC systems. > >> These platforms do not have a /sas/ within their path. Over time > >> different OF addressing schemes have been supported. There > >> is no generic addressing scheme that works across every HBA. > >> > >> Signed-off-by: Eric Snowberg > >> --- > >> grub-core/osdep/linux/ofpath.c | 147 +++++++++++++++++++++++++++++++= +++++++++- > >> 1 file changed, 144 insertions(+), 3 deletions(-) > >> > >> diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/= ofpath.c > >> index 3a8bc95a9..525a42ae6 100644 > >> --- a/grub-core/osdep/linux/ofpath.c > >> +++ b/grub-core/osdep/linux/ofpath.c > >> @@ -38,6 +38,44 @@ > >> #include > >> #include > >> > >> +#ifdef __sparc__ > > > > This is not good. It will not work if you cross compile. > > What error do you see on a cross compile? I see __sparc__ used through= out the code. It seems to me that Vladimir (CC-ed) complained about that somewhere. However, it looks that this check is OK. So, if Vladimir is OK with that we can leave it as is. [...] > >> +static void > >> +check_hba_identifiers (const char *sysfs_path, int *vendor, int *de= vice_id) > >> +{ > >> + char *ed =3D strstr (sysfs_path, "host"); > >> + size_t path_size; > >> + char *p =3D NULL, *path =3D NULL; > > > > I think that you do not need to initialize *p here. > > I=E2=80=99ll remove the initialization. Thanks! > >> + char buf[8]; > >> + int fd; > >> + > >> + if (!ed) > >> + return; > >> + > >> + p =3D xstrdup (sysfs_path); > > > > Why do you need to duplicate sysfs_path? > > I do not think it is needed. Just p =3D sysfs_path? > > This is duplicated since the result of p is modified ... > > > > >> + ed =3D strstr (p, "host"); > >> + > >> + if (!ed) > >> + goto out; > >> + > >> + *ed =3D '\0=E2=80=99; > > right here. If I didn=E2=80=99t duplicate the string, it would corrupt > the sysfs_path. Also, sysfs_path is defined as const char *. Ahhh... Right I have missed that. Sorry. > >> + > >> + path_size =3D (strlen (p) + sizeof ("vendor")); > >> + path =3D xmalloc (path_size); > >> + > >> + if (!path) > >> + goto out; > >> + > >> + snprintf (path, path_size, "%svendor", p); > >> + fd =3D open (path, O_RDONLY); > >> + > >> + if (fd < 0) > >> + goto out; > >> + > >> + memset (buf, 0, sizeof (buf)); > >> + > >> + if (read (fd, buf, sizeof (buf) - 1) < 0) > >> + goto out; > >> + > >> + close (fd); > >> + sscanf (buf, "%x", vendor); > > > > Please add empty line here. > > > >> + snprintf (path, path_size, "%sdevice", p); > > > > I have a feeling that p should be changed somehow here > > or to be precise a bit earlier... Should not it? > > It is being changed above? *ed is a pointer within it. Yes, but only once. Later string pointed by p is not changed. The same value is used for "%svendor" and "%sdevice". Is it correct? Am I missing something? [...] > > In general I am not happy with sscanf() usage as a string to number > > converter. Especially without any error checking. However, as I can > > see, it is common here. So, I will accept fixed patch with sscanf() > > eventually but I would be happy if you replace it everywhere with > > something more robust in separate patch. > > I could look at doing that in the future. I always try to follow the > coding style within the file. Great! Thanks! Daniel