aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-08-22 10:34:40 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-08-22 10:34:40 -0700
commit6bc9a8305bca8c933da90481f536407b733b806f (patch)
tree9badd4478a322ed163d7cfb70ee91fc134d4c98b
parentb3514f90bf55e5a1f277cbcf83afa509b9d13acc (diff)
downloadsyslinux-6bc9a8305bca8c933da90481f536407b733b806f.tar.gz
syslinux-6bc9a8305bca8c933da90481f536407b733b806f.tar.xz
syslinux-6bc9a8305bca8c933da90481f536407b733b806f.zip
hdt: make get_error behaves like perror
This simplifies buffer handling. Misc.: clean some old error code handling. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
-rw-r--r--com32/gplinclude/disk/errno_disk.h3
-rw-r--r--com32/gpllib/disk/error.c7
-rw-r--r--com32/hdt/hdt-cli-disk.c15
-rw-r--r--com32/hdt/hdt-common.c7
-rw-r--r--com32/hdt/hdt-menu-disk.c8
5 files changed, 9 insertions, 31 deletions
diff --git a/com32/gplinclude/disk/errno_disk.h b/com32/gplinclude/disk/errno_disk.h
index 055eaf58..60b511fc 100644
--- a/com32/gplinclude/disk/errno_disk.h
+++ b/com32/gplinclude/disk/errno_disk.h
@@ -10,9 +10,6 @@
#ifndef _ERRNO_DISK_H
#define _ERRNO_DISK_H
-/* Max length of the error string */
-#define MAX_DISK_ERRNO 9
-
extern int errno_disk;
/* Prefix with ED to avoid confusion with errno */
diff --git a/com32/gpllib/disk/error.c b/com32/gpllib/disk/error.c
index 2b82c359..1853092b 100644
--- a/com32/gpllib/disk/error.c
+++ b/com32/gpllib/disk/error.c
@@ -8,8 +8,7 @@
* ----------------------------------------------------------------------- */
#include <stdio.h>
-#include <stdlib.h>
-
+#include <string.h>
#include <disk/errno_disk.h>
/**
@@ -18,7 +17,7 @@
*
* Fill @buffer_ptr with the last errno_disk
**/
-void get_error(void* buffer_ptr)
+void get_error(const char* s)
{
- snprintf(buffer_ptr, MAX_DISK_ERRNO, "Disklib: error %d\n", errno_disk);
+ fprintf(stderr, "%s: error %d\n", s, errno_disk);
}
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index 080e1327..fec98a15 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -64,8 +64,6 @@ static void show_partition_information(struct driveinfo *drive_info,
{
char size[9];
char *parttype;
- int error = 0;
- char error_buffer[MAX_DISK_ERRNO];
unsigned int start, end;
int i = nb_partitions_seen;
@@ -90,12 +88,8 @@ static void show_partition_information(struct driveinfo *drive_info,
ptab->ostype, parttype);
/* Extra info */
- if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab)) {
+ if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab))
more_printf("%s", " (Swsusp sig. detected)");
- } else if (error) {
- get_error(&error_buffer);
- more_printf("%s\n", error_buffer);
- }
more_printf("\n");
@@ -120,7 +114,6 @@ void main_show_disk(int argc, char **argv,
int i = drive - 0x80;
struct driveinfo *d = &hardware->disk_info[i];
- char error_buffer[MAX_DISK_ERRNO];
char disk_size[9];
detect_disks(hardware);
@@ -143,9 +136,9 @@ void main_show_disk(int argc, char **argv,
disk_size, (int) d->edd_params.bytes_per_sector, (int) d->edd_params.sectors_per_track,
remove_spaces(d->edd_params.host_bus_type), remove_spaces(d->edd_params.interface_type));
- if (parse_partition_table(d, &show_partition_information) == -1) {
- get_error(&error_buffer);
- more_printf("%s\n", error_buffer);
+ if (parse_partition_table(d, &show_partition_information)) {
+ fprintf(stderr, "Error parsing disk 0x%X\n", d->disk);
+ get_error("parse_partition_table");
}
}
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 0f98ab9e..80305a3e 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -252,7 +252,6 @@ void detect_disks(struct s_hardware *hardware)
{
int i = -1;
int err;
- char *error_msg;
if (hardware->disk_detection)
return;
@@ -270,12 +269,6 @@ void detect_disks(struct s_hardware *hardware)
if (err == -1 || !hardware->disk_info[i].cbios)
continue;
- if (err) {
- get_error(err, &error_msg);
- more_printf("Error 0x%Xh while reading disk 0x%X:\n\t%s\n",
- err, drive, error_msg);
- free(error_msg);
- }
hardware->disks_count++;
}
}
diff --git a/com32/hdt/hdt-menu-disk.c b/com32/hdt/hdt-menu-disk.c
index e5644078..bd33bdf3 100644
--- a/com32/hdt/hdt-menu-disk.c
+++ b/com32/hdt/hdt-menu-disk.c
@@ -210,12 +210,8 @@ static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
dn=disk_number;
parse_partition_table(&d[disk_number], &show_partition_information);
- if (parse_partition_table(&d[disk_number], &compute_partition_information) == -1) {
- char error_buffer[MAX_DISK_ERRNO];
- get_error(&error_buffer);
- snprintf(buffer, sizeof buffer, "I/O error : %s", error_buffer);
- snprintf(statbuffer, sizeof statbuffer, "I/O error : %s", error_buffer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ if (!parse_partition_table(&d[disk_number], &compute_partition_information)) {
+ get_error("parse_partition_table");
menu[nb_sub_disk_menu].items_count++;
}