Some pxe fixes.]
PATCH 1/1 Some pxe fixes.]
Hi,
I was toying with pxe and noticed some errors in the code small errors in the code. In the file read method it is possible to return error codes instead of amount read. This patch fix that by setting the error and returning -1 instead. It also fix some coding style by removing tabs and use UNUSED macro.
Michel
ChangeLog +6 -0
@@ -1,3 +1,9 @@ +2009-05-01 Michel Hermier <[email protected]> + + * fs/i386/pc/pxe.c (grub_pxefs_read): Fix returned values. + Returning error codes as grub_size_t is a bad idea. Fixing + indent style and use UNUSED macro while at it. + 2009-04-30 David S. Miller <[email protected]> * util/hostdisk.c (device_is_wholedisk): New function.
i386/pc/pxe.c +22 -16
@@ -72,24 +72,24 @@ }static void -grub_pxe_close (grub_disk_t disk __attribute((unused))) +grub_pxe_close (grub_disk_t disk UNUSED) { }static grub_err_t -grub_pxe_read (grub_disk_t disk __attribute((unused)), -grub_disk_addr_t sector __attribute((unused)), -grub_size_t size __attribute((unused)), -char *buf __attribute((unused))) +grub_pxe_read (grub_disk_t disk UNUSED, + grub_disk_addr_t sector UNUSED, + grub_size_t size UNUSED, + char *buf UNUSED) {return GRUB_ERR_OUT_OF_RANGE ; }static grub_err_t -grub_pxe_write (grub_disk_t disk __attribute((unused)), -grub_disk_addr_t sector __attribute((unused)), -grub_size_t size __attribute((unused)), -const char *buf __attribute((unused))) +grub_pxe_write (grub_disk_t disk UNUSED, + grub_disk_addr_t sector UNUSED, + grub_size_t size UNUSED, + const char *buf UNUSED) {return GRUB_ERR_OUT_OF_RANGE ; }
@@ -108,8 +108,8 @@static grub_err_t grub_pxefs_dir (grub_device_t device UNUSED, const char *path UNUSED, -int (*hook) (const char *filename, -const struct grub_dirhook_info *info)UNUSED ) +int (*hook) (const char *filename, +const struct grub_dirhook_info *info)UNUSED ) {return GRUB_ERR_NONE ; }
@@ -189,8 +189,11 @@ pn =grub_divmod64 (file->offset, data->block_size, &r);if (r) -return grub_error (GRUB_ERR_BAD_FS , -"read access must be aligned to packet size" ); + { +grub_error (GRUB_ERR_BAD_FS , +"read access must be aligned to packet size" ); +return -1 ; + }if ((curr_file != file) || (data->packet_number > pn)) {
@@ -206,7 +209,10 @@ o.packet_size = data->block_size;grub_pxe_call (GRUB_PXENV_TFTP_OPEN , &o);if (o.status) -return grub_error (GRUB_ERR_BAD_FS ,"open fails" ); + { +grub_error (GRUB_ERR_BAD_FS ,"open fails" ); +return -1 ; + } data->packet_number =0 ; curr_file = file; }
@@ -246,8 +252,8 @@ }static grub_err_t -grub_pxefs_label (grub_device_t device __attribute ((unused)), -char **label __attribute ((unused))) +grub_pxefs_label (grub_device_t device UNUSED, + char **label UNUSED) { *label =0 ;return GRUB_ERR_NONE ;
Hello. Sorry that this mail was overlooked
Quoted 6 lines · Michel Hermier
Hi,
I was toying with pxe and noticed some errors in the code small errors in the code. In the file read method it is possible to return error codes instead of amount read. This patch fix that by setting the error and returning -1 instead.
Comitted this part. Thank you for noticing this bug
Quoted 2 lines
It also fix some coding style by removing tabs
and use UNUSED macro.
grub2 equally uses the both approaches. Unless it creates problems with compilers I don't see any urge to make it uniform
Quoted 112 lines
Michel
Index: ChangeLog
===================================================================ChangeLog (copie de travail) renamed from ChangeLog (révision 2154) +6
-0@@ -1,3 +1,9 @@ +2009-05-01 Michel Hermier <[email protected]> + + * fs/i386/pc/pxe.c (grub_pxefs_read): Fix returned values. + Returning error codes as grub_size_t is a bad idea. Fixing + indent style and use UNUSED macro while at it. +2009-04-30 David S. Miller <[email protected]>
*
util/hostdisk.c(device_is_wholedisk): New function.
Index:fs/i386/pc/pxe.c
===================================================================i386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +0
-0@@ -72,24 +72,24 @@ }static void
i386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +1
-1-grub_pxe_close (grub_disk_t disk __attribute((unused))) +grub_pxe_close (grub_disk_t disk UNUSED){
}static
grub_err_ti386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +4
-4-grub_pxe_read (grub_disk_t disk __attribute((unused)), - grub_disk_addr_t sector __attribute((unused)), - grub_size_t size __attribute((unused)), - char *buf __attribute((unused))) +grub_pxe_read (grub_disk_t disk UNUSED, + grub_disk_addr_t sector UNUSED, + grub_size_t size UNUSED, + char *buf UNUSED){
returnGRUB_ERR_OUT_OF_RANGE;
}static
grub_err_ti386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +4
-4-grub_pxe_write (grub_disk_t disk __attribute((unused)), - grub_disk_addr_t sector __attribute((unused)), - grub_size_t size __attribute((unused)), - const char *buf __attribute((unused))) +grub_pxe_write (grub_disk_t disk UNUSED, + grub_disk_addr_t sector UNUSED, + grub_size_t size UNUSED, + const char *buf UNUSED){
returnGRUB_ERR_OUT_OF_RANGE;
}i386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +0
-0@@ -108,8 +108,8 @@static
grub_err_t
grub_pxefs_dir (grub_device_tdevice UNUSED, const char *path UNUSED,
- int (*hook) (const char *filename,
- const structgrub_dirhook_info*info) UNUSED)
+ int (*hook) (const char *filename,
+ const structgrub_dirhook_info*info) UNUSED) {
returnGRUB_ERR_NONE;
}i386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +9
-3@@ -189,8 +189,11 @@ pn = grub_divmod64 (file->offset, data->block_size, &r); if (r) - return grub_error (GRUB_ERR_BAD_FS, - "read access must be aligned to packet size"); + { + grub_error (GRUB_ERR_BAD_FS, + "read access must be aligned to packet size"); + return -1; + } if ((curr_file != file) || (data->packet_number > pn)) {@@ -206,7 +209,10 @@ o.packet_size = data->block_size; grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &o); if (o.status) - return grub_error (GRUB_ERR_BAD_FS, "open fails"); + { + grub_error (GRUB_ERR_BAD_FS, "open fails"); + return -1; + } data->packet_number = 0; curr_file = file; }@@ -246,8 +252,8 @@ }static
grub_err_ti386/pc/pxe.c (copie de travail) renamed from i386/pc/pxe.c (révision 2154) +2
-2-grub_pxefs_label (grub_device_t device __attribute ((unused)), - char **label __attribute ((unused))) +grub_pxefs_label (grub_device_t device UNUSED, + char **label UNUSED){
*label = 0;
returnGRUB_ERR_NONE;_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko