Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ettaF-0005Iu-8K for mharc-grub-devel@gnu.org; Thu, 08 Mar 2018 06:19:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ettaC-0005G2-GA for grub-devel@gnu.org; Thu, 08 Mar 2018 06:19:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etta9-0002G5-9c for grub-devel@gnu.org; Thu, 08 Mar 2018 06:19:36 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etta8-0002Fb-VN for grub-devel@gnu.org; Thu, 08 Mar 2018 06:19:33 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w28BHmD2179370 for ; Thu, 8 Mar 2018 11:19:31 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 : in-reply-to; s=corp-2017-10-26; bh=0ENen+4bHuDCdIZL3ena6dk7vEA0YRdCLPUXkW1MXR0=; b=Q0BH27aasdQGLuKgwyNxHeYq5dsUJNF0nmhsrsbPZkkzDICYBFxwwhSa2TV6WXgNa/W5 00dwzFpl0iSyvxxFIC9I43Xwbbr8qBPAJdqebpjFd3b8n0yTPCyk7wxqv2cKfRvP+Mbw im615its3iYlNjDcD99IQRZjpiKiPzJ+0tMMDroRiTRCd1fYzpkSsRThyuDexLp4ly8O tcKxLAs8XsbDc6MKxwRpnLFWVpFkRwzMIbX/q76kOXEzxtvPYDrC3ugnATfaXSysRbwk CItFIP/uoryc8riIvn14hjEd7UrrCA3pNQ3rUaj+ngAAzOkstqhrDVRFImLvFMuhQM6g Sg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2gk42281ak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 08 Mar 2018 11:19:31 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w28BJU4h015800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 8 Mar 2018 11:19:30 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w28BJTLT005865 for ; Thu, 8 Mar 2018 11:19:30 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 03:19:29 -0800 Date: Thu, 8 Mar 2018 12:19:25 +0100 From: Daniel Kiper To: Eric Snowberg Cc: grub-devel@gnu.org Subject: Re: [PATCH] ieee1275: split up grub_machine_get_bootlocation Message-ID: <20180308111925.GW20614@olila.local.net-space.pl> References: <1520459290-145494-1-git-send-email-eric.snowberg@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520459290-145494-1-git-send-email-eric.snowberg@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8825 signatures=668685 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-1803080133 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 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 11:19:37 -0000 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 follow on > patch. I would like to see follow up patches in such cases like that one. > 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/ieee1275/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 *dev, char **device, char **path, > void > grub_machine_get_bootlocation (char **device, char **path) > { > - char *bootpath; > - grub_ssize_t bootpath_size; > + char *bootpath = NULL; I do not think that you need initialize this if... > char *filename; > char *type; > > - if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", > - &bootpath_size) > - || bootpath_size <= 0) > - { > - /* Should never happen. */ > - grub_printf ("/chosen/bootpath property missing!\n"); > - return; > - } > - > - bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); > - if (! bootpath) > - { > - grub_print_error (); > - return; > - } > - grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, > - (grub_size_t) bootpath_size + 1, 0); > - bootpath[bootpath_size] = '\0'; > + grub_ieee1275_get_boot_dev (&bootpath); > + if (bootpath == NULL) if (! bootpath) > + return; > > /* Transform an OF device path to a GRUB path. */ > > diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/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... Daniel