Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ety0h-0006M6-2n for mharc-grub-devel@gnu.org; Thu, 08 Mar 2018 11:03:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ety0b-0006J7-JC for grub-devel@gnu.org; Thu, 08 Mar 2018 11:03:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ety0W-00007H-Lf for grub-devel@gnu.org; Thu, 08 Mar 2018 11:03:09 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:44434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ety0W-00006d-8j for grub-devel@gnu.org; Thu, 08 Mar 2018 11:03:04 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w28G2Qr9126116 for ; Thu, 8 Mar 2018 16:03:01 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=Kna6YbcltI7NDIiGHDrQXYA5ogDqfaLRqR2RcUMadz4=; b=XOTeai6S9jad/cMZ/OJ54etMvoiMsmoxKruwNKiTa1Q9aI4t50KPYnhebGX3MLnCXiEs BSe3nTLC2EKJXvMWaSP6RJHth5aWa18Qq674Gr74vwiYsa4Agw+I7m0vLCM2NQSBTh33 weQ+FpNnOIy1iGO41wzXeqZaTVr1aQc5OUWQgBldX9tz7ghkagJ6v8fCHmsRti3PoBF2 cgkvKTZKH0mcJ6Qubwq8YOfN02T1mppYa/5vC2IH61sjHonQL7ze+msXuUFnEfDpi+kG FhHCMjsKdM8QHeIiu+7LZwR38QuP9QvcGqTK9sFYo6Sxg9sNbBKdjQzI1+MxYdBpbVD9 lw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2gk7bw0fc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 08 Mar 2018 16:03:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w28G30fU014055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 8 Mar 2018 16:03:00 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w28G30IW005646 for ; Thu, 8 Mar 2018 16:03:00 GMT Received: from olila.local.net-space.pl (/10.175.169.20) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Mar 2018 08:03:00 -0800 Date: Thu, 8 Mar 2018 17:02:55 +0100 From: Daniel Kiper To: Eric Snowberg Cc: The development of GNU GRUB Subject: Re: [PATCH] ieee1275: split up grub_machine_get_bootlocation Message-ID: <20180308160255.GZ20614@olila.local.net-space.pl> References: <1520459290-145494-1-git-send-email-eric.snowberg@oracle.com> <20180308111925.GW20614@olila.local.net-space.pl> <7D132172-B7DA-4072-961A-D46760AE1604@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7D132172-B7DA-4072-961A-D46760AE1604@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8826 signatures=668687 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-1803080185 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2120.oracle.com id w28G2Qr9126116 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: Thu, 08 Mar 2018 16:03:14 -0000 On Thu, Mar 08, 2018 at 08:42:14AM -0700, Eric Snowberg wrote: > > > On Mar 8, 2018, at 4:19 AM, Daniel Kiper wr= ote: > > > > On Wed, Mar 07, 2018 at 01:48:10PM -0800, Eric Snowberg wrote: > >> Split up some of the functionality in grub_machine_get_bootlocation = into > >> grub_ieee1275_get_boot_dev. This will allow for code reuse in a fol= low on > >> patch. > > > > I would like to see follow up patches in such cases like that one. > > Here is the follow up patch I=E2=80=99m preparing to send that will use= it (look at the add_bootpath function): > > https://github.com/esnowberg/grub2-sparc/commit/94e4e64c98bce8f43ced440= 928b3d1e83b36ed11.patch > > This patch also uses the other additions I=E2=80=99ve sent recently. > > > > >> Signed-off-by: Eric Snowberg > >> --- > >> grub-core/kern/ieee1275/init.c | 24 ++++-------------------- > >> grub-core/kern/ieee1275/openfw.c | 27 +++++++++++++++++++++++++++ > >> include/grub/ieee1275/ieee1275.h | 1 + > >> 3 files changed, 32 insertions(+), 20 deletions(-) > >> > >> diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee127= 5/init.c > >> index 1259022..dff2184 100644 > >> --- a/grub-core/kern/ieee1275/init.c > >> +++ b/grub-core/kern/ieee1275/init.c > >> @@ -93,29 +93,13 @@ void (*grub_ieee1275_net_config) (const char *de= v, char **device, char **path, > >> void > >> grub_machine_get_bootlocation (char **device, char **path) > >> { > >> - char *bootpath; > >> - grub_ssize_t bootpath_size; > >> + char *bootpath =3D NULL; > > > > I do not think that you need initialize this if=E2=80=A6 > > I thought the compiler complained about that, but I=E2=80=99ll try to r= emove it. > > > > >> char *filename; > >> char *type; > >> > >> - if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "boo= tpath", > >> - &bootpath_size) > >> - || bootpath_size <=3D 0) > >> - { > >> - /* Should never happen. */ > >> - grub_printf ("/chosen/bootpath property missing!\n"); > >> - return; > >> - } > >> - > >> - bootpath =3D (char *) grub_malloc ((grub_size_t) bootpath_size + = 64); > >> - if (! bootpath) > >> - { > >> - grub_print_error (); > >> - return; > >> - } > >> - grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", boo= tpath, > >> - (grub_size_t) bootpath_size + 1, 0); > >> - bootpath[bootpath_size] =3D '\0'; > >> + grub_ieee1275_get_boot_dev (&bootpath); > >> + if (bootpath =3D=3D NULL) > > > > if (! bootpath) > > I=E2=80=99ll make this change. > > > > >> + return; > >> > >> /* Transform an OF device path to a GRUB path. */ > >> > >> diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1= 275/openfw.c > >> index ddb7783..81c03cf 100644 > >> --- a/grub-core/kern/ieee1275/openfw.c > >> +++ b/grub-core/kern/ieee1275/openfw.c > >> @@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char = *path) > >> return NULL; > >> } > >> > >> +void > >> +grub_ieee1275_get_boot_dev (char **boot_dev) > > > > ...you return char * here=E2=80=A6 > > The returned value is in the boot_dev. Just to clarify, you want me to= change the function prototype to return char * too? Sorry, I was not clear enough. I though about: char * grub_ieee1275_get_boot_dev (void) { ... } Daniel