From 6d5c2ed68a8b5f126c2eec349e39496af86d63ab Mon Sep 17 00:00:00 2001 From: Manoel Rebelo Abranches Date: Fri, 1 Apr 2011 05:27:06 -0300 Subject: [PATCH] Use nb in all function declarations for consistency. --- grub-core/net/netbuff.c | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c index cc366ae09..be9fc9de2 100644 --- a/grub-core/net/netbuff.c +++ b/grub-core/net/netbuff.c @@ -22,43 +22,43 @@ #include -grub_err_t grub_netbuff_put (struct grub_net_buff *net_buff ,grub_size_t len) +grub_err_t grub_netbuff_put (struct grub_net_buff *nb ,grub_size_t len) { - net_buff->tail += len; - if (net_buff->tail > net_buff->end) + nb->tail += len; + if (nb->tail > nb->end) return grub_error (GRUB_ERR_OUT_OF_RANGE, "put out of the packet range."); return GRUB_ERR_NONE; } -grub_err_t grub_netbuff_unput (struct grub_net_buff *net_buff ,grub_size_t len) +grub_err_t grub_netbuff_unput (struct grub_net_buff *nb ,grub_size_t len) { - net_buff->tail -= len; - if (net_buff->tail < net_buff->head) + nb->tail -= len; + if (nb->tail < nb->head) return grub_error (GRUB_ERR_OUT_OF_RANGE, "unput out of the packet range."); return GRUB_ERR_NONE; } -grub_err_t grub_netbuff_push (struct grub_net_buff *net_buff ,grub_size_t len) +grub_err_t grub_netbuff_push (struct grub_net_buff *nb ,grub_size_t len) { - net_buff->data -= len; - if (net_buff->data < net_buff->head) + nb->data -= len; + if (nb->data < nb->head) return grub_error (GRUB_ERR_OUT_OF_RANGE, "push out of the packet range."); return GRUB_ERR_NONE; } -grub_err_t grub_netbuff_pull (struct grub_net_buff *net_buff ,grub_size_t len) +grub_err_t grub_netbuff_pull (struct grub_net_buff *nb ,grub_size_t len) { - net_buff->data += len; - if (net_buff->data > net_buff->end) + nb->data += len; + if (nb->data > nb->end) return grub_error (GRUB_ERR_OUT_OF_RANGE, "pull out of the packet range."); return GRUB_ERR_NONE; } -grub_err_t grub_netbuff_reserve (struct grub_net_buff *net_buff ,grub_size_t len) +grub_err_t grub_netbuff_reserve (struct grub_net_buff *nb ,grub_size_t len) { - net_buff->data += len; - net_buff->tail += len; - if ((net_buff->tail > net_buff->end) || (net_buff->data > net_buff->end)) + nb->data += len; + nb->tail += len; + if ((nb->tail > nb->end) || (nb->data > nb->end)) return grub_error (GRUB_ERR_OUT_OF_RANGE, "reserve out of the packet range."); return GRUB_ERR_NONE; } @@ -73,22 +73,23 @@ struct grub_net_buff *grub_netbuff_alloc ( grub_size_t len ) len = ALIGN_UP (len,NETBUFF_ALIGN); data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb)); + if (!data) + return NULL; nb = (struct grub_net_buff *) ((grub_uint8_t *) data + len); nb->head = nb->data = nb->tail = data; - nb->end = (char *) nb; - + nb->end = (char *) nb; return nb; } -grub_err_t grub_netbuff_free (struct grub_net_buff *net_buff) +grub_err_t grub_netbuff_free (struct grub_net_buff *nb) { - grub_free (net_buff->head); + grub_free (nb->head); return 0; } -grub_err_t grub_netbuff_clear (struct grub_net_buff *net_buff) +grub_err_t grub_netbuff_clear (struct grub_net_buff *nb) { - net_buff->data = net_buff->tail = net_buff->head; + nb->data = nb->tail = nb->head; return 0; }