From f8614119a02110e8ccd69499b5a03147e9535372 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 26 Jun 2011 22:38:43 +0200 Subject: [PATCH] Few ofnet cleanups --- grub-core/net/drivers/ieee1275/ofnet.c | 47 ++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 2c264edb1..48c3cd635 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -1,3 +1,21 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010,2011 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + #include #include #include @@ -37,7 +55,8 @@ card_close (struct grub_net_card *dev) } static grub_err_t -send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack) +send_card_buffer (const struct grub_net_card *dev, + struct grub_net_buff *pack) { int actual; int status; @@ -52,7 +71,8 @@ send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack) } static grub_ssize_t -get_card_packet (struct grub_net_card *dev, struct grub_net_buff *nb) +get_card_packet (const struct grub_net_card *dev, + struct grub_net_buff *nb) { int actual, rc; @@ -125,20 +145,33 @@ grub_getbootp_real (void) static void grub_ofnet_findcards (void) { - struct grub_net_card *card; - grub_ieee1275_phandle_t devhandle; - grub_net_link_level_address_t lla; int i = 0; + auto int search_net_devices (struct grub_ieee1275_devalias *alias); int search_net_devices (struct grub_ieee1275_devalias *alias) { if (!grub_strcmp (alias->type, "network")) { + struct grub_ofnetcard_data *ofdata; + struct grub_net_card *card; + grub_ieee1275_phandle_t devhandle; + grub_net_link_level_address_t lla; + ofdata = grub_malloc (sizeof (struct grub_ofnetcard_data)); + if (!ofdata) + { + grub_print_error (); + return 1; + } card = grub_malloc (sizeof (struct grub_net_card)); - struct grub_ofnetcard_data *ofdata = - grub_malloc (sizeof (struct grub_ofnetcard_data)); + if (!card) + { + grub_free (ofdata); + grub_print_error (); + return 1; + } + ofdata->path = grub_strdup (alias->path); grub_ieee1275_finddevice (ofdata->path, &devhandle);