diff options
author | Matt Kraai <kraai@debian.org> | 2000-12-22 01:48:07 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-12-22 01:48:07 +0000 |
commit | a9819b290848e0a760f3805d5937fa050235d707 (patch) | |
tree | b8cb8d939032c0806d62161b01e5836cb808dc3f /console-tools | |
parent | e9f07fb6e83b75a50760599a5d31f494841eddf7 (diff) | |
download | busybox-w32-a9819b290848e0a760f3805d5937fa050235d707.tar.gz busybox-w32-a9819b290848e0a760f3805d5937fa050235d707.tar.bz2 busybox-w32-a9819b290848e0a760f3805d5937fa050235d707.zip |
Use busybox error handling functions wherever possible.
Diffstat (limited to 'console-tools')
-rw-r--r-- | console-tools/deallocvt.c | 12 | ||||
-rw-r--r-- | console-tools/loadacm.c | 47 |
2 files changed, 23 insertions, 36 deletions
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index b128c3fae..3dd90c0e9 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c | |||
@@ -25,10 +25,8 @@ int deallocvt_main(int argc, char *argv[]) | |||
25 | 25 | ||
26 | if (argc == 1) { | 26 | if (argc == 1) { |
27 | /* deallocate all unused consoles */ | 27 | /* deallocate all unused consoles */ |
28 | if (ioctl(fd, VT_DISALLOCATE, 0)) { | 28 | if (ioctl(fd, VT_DISALLOCATE, 0)) |
29 | perror("VT_DISALLOCATE"); | 29 | perror_msg_and_die("VT_DISALLOCATE"); |
30 | return EXIT_FAILURE; | ||
31 | } | ||
32 | } else { | 30 | } else { |
33 | for (i = 1; i < argc; i++) { | 31 | for (i = 1; i < argc; i++) { |
34 | num = atoi(argv[i]); | 32 | num = atoi(argv[i]); |
@@ -36,10 +34,8 @@ int deallocvt_main(int argc, char *argv[]) | |||
36 | error_msg("0: illegal VT number\n"); | 34 | error_msg("0: illegal VT number\n"); |
37 | else if (num == 1) | 35 | else if (num == 1) |
38 | error_msg("VT 1 cannot be deallocated\n"); | 36 | error_msg("VT 1 cannot be deallocated\n"); |
39 | else if (ioctl(fd, VT_DISALLOCATE, num)) { | 37 | else if (ioctl(fd, VT_DISALLOCATE, num)) |
40 | perror("VT_DISALLOCATE"); | 38 | perror_msg_and_die("VT_DISALLOCATE"); |
41 | error_msg_and_die("could not deallocate console %d\n", num); | ||
42 | } | ||
43 | } | 39 | } |
44 | } | 40 | } |
45 | 41 | ||
diff --git a/console-tools/loadacm.c b/console-tools/loadacm.c index 52702bf6d..040062cf8 100644 --- a/console-tools/loadacm.c +++ b/console-tools/loadacm.c | |||
@@ -60,7 +60,7 @@ int screen_map_load(int fd, FILE * fp) | |||
60 | int is_unicode; | 60 | int is_unicode; |
61 | 61 | ||
62 | if (fstat(fileno(fp), &stbuf)) | 62 | if (fstat(fileno(fp), &stbuf)) |
63 | perror("Cannot stat map file"), exit(1); | 63 | perror_msg_and_die("Cannot stat map file"); |
64 | 64 | ||
65 | /* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */ | 65 | /* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */ |
66 | if (! | 66 | if (! |
@@ -70,15 +70,13 @@ int screen_map_load(int fd, FILE * fp) | |||
70 | if (parse_failed) { | 70 | if (parse_failed) { |
71 | if (-1 == fseek(fp, 0, SEEK_SET)) { | 71 | if (-1 == fseek(fp, 0, SEEK_SET)) { |
72 | if (errno == ESPIPE) | 72 | if (errno == ESPIPE) |
73 | error_msg("16bit screen-map MUST be a regular file.\n"), | 73 | error_msg_and_die("16bit screen-map MUST be a regular file.\n"); |
74 | exit(1); | ||
75 | else | 74 | else |
76 | perror("fseek failed reading binary 16bit screen-map"), | 75 | perror_msg_and_die("fseek failed reading binary 16bit screen-map"); |
77 | exit(1); | ||
78 | } | 76 | } |
79 | 77 | ||
80 | if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) | 78 | if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) |
81 | perror("Cannot read [new] map from file"), exit(1); | 79 | perror_msg_and_die("Cannot read [new] map from file"); |
82 | #if 0 | 80 | #if 0 |
83 | else | 81 | else |
84 | error_msg("Input screen-map is binary.\n"); | 82 | error_msg("Input screen-map is binary.\n"); |
@@ -89,7 +87,7 @@ int screen_map_load(int fd, FILE * fp) | |||
89 | /* same if it was binary, ie. if parse_failed */ | 87 | /* same if it was binary, ie. if parse_failed */ |
90 | if (parse_failed || is_unicode) { | 88 | if (parse_failed || is_unicode) { |
91 | if (ioctl(fd, PIO_UNISCRNMAP, wbuf)) | 89 | if (ioctl(fd, PIO_UNISCRNMAP, wbuf)) |
92 | perror("PIO_UNISCRNMAP ioctl"), exit(1); | 90 | perror_msg_and_die("PIO_UNISCRNMAP ioctl"); |
93 | else | 91 | else |
94 | return 0; | 92 | return 0; |
95 | } | 93 | } |
@@ -101,7 +99,7 @@ int screen_map_load(int fd, FILE * fp) | |||
101 | error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"), | 99 | error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"), |
102 | exit(1); | 100 | exit(1); |
103 | else | 101 | else |
104 | perror("fseek failed assuming 8bit screen-map"), exit(1); | 102 | perror_msg_and_die("fseek failed assuming 8bit screen-map"); |
105 | } | 103 | } |
106 | 104 | ||
107 | /* ... and try an old 8-bit screen-map */ | 105 | /* ... and try an old 8-bit screen-map */ |
@@ -111,14 +109,13 @@ int screen_map_load(int fd, FILE * fp) | |||
111 | if (-1 == fseek(fp, 0, SEEK_SET)) { | 109 | if (-1 == fseek(fp, 0, SEEK_SET)) { |
112 | if (errno == ESPIPE) | 110 | if (errno == ESPIPE) |
113 | /* should not - it succedeed above */ | 111 | /* should not - it succedeed above */ |
114 | error_msg("fseek() returned ESPIPE !\n"), | 112 | error_msg_and_die("fseek() returned ESPIPE !\n"); |
115 | exit(1); | ||
116 | else | 113 | else |
117 | perror("fseek for binary 8bit screen-map"), exit(1); | 114 | perror_msg_and_die("fseek for binary 8bit screen-map"); |
118 | } | 115 | } |
119 | 116 | ||
120 | if (fread(buf, E_TABSZ, 1, fp) != 1) | 117 | if (fread(buf, E_TABSZ, 1, fp) != 1) |
121 | perror("Cannot read [old] map from file"), exit(1); | 118 | perror_msg_and_die("Cannot read [old] map from file"); |
122 | #if 0 | 119 | #if 0 |
123 | else | 120 | else |
124 | error_msg("Input screen-map is binary.\n"); | 121 | error_msg("Input screen-map is binary.\n"); |
@@ -126,7 +123,7 @@ int screen_map_load(int fd, FILE * fp) | |||
126 | } | 123 | } |
127 | 124 | ||
128 | if (ioctl(fd, PIO_SCRNMAP, buf)) | 125 | if (ioctl(fd, PIO_SCRNMAP, buf)) |
129 | perror("PIO_SCRNMAP ioctl"), exit(1); | 126 | perror_msg_and_die("PIO_SCRNMAP ioctl"); |
130 | else | 127 | else |
131 | return 0; | 128 | return 0; |
132 | } | 129 | } |
@@ -174,10 +171,8 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode) | |||
174 | if (NULL == fgets(buffer, sizeof(buffer), fp)) { | 171 | if (NULL == fgets(buffer, sizeof(buffer), fp)) { |
175 | if (feof(fp)) | 172 | if (feof(fp)) |
176 | break; | 173 | break; |
177 | else { | 174 | else |
178 | perror("uni_screen_map_read_ascii() can't read line"); | 175 | perror_msg_and_die("uni_screen_map_read_ascii() can't read line"); |
179 | exit(2); | ||
180 | } | ||
181 | } | 176 | } |
182 | 177 | ||
183 | /* get "charset-relative charcode", stripping leading spaces */ | 178 | /* get "charset-relative charcode", stripping leading spaces */ |
@@ -317,12 +312,11 @@ void saveoldmap(int fd, char *omfil) | |||
317 | int is_old_map = 0; | 312 | int is_old_map = 0; |
318 | 313 | ||
319 | if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) { | 314 | if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) { |
320 | perror("GIO_UNISCRNMAP ioctl error"); | 315 | perror_msg("GIO_UNISCRNMAP ioctl error"); |
321 | #endif | 316 | #endif |
322 | if (ioctl(fd, GIO_SCRNMAP, buf)) { | 317 | if (ioctl(fd, GIO_SCRNMAP, buf)) |
323 | perror("GIO_SCRNMAP ioctl error"); | 318 | perror_msg_and_die("GIO_SCRNMAP ioctl error"); |
324 | exit(1); | 319 | else |
325 | } else | ||
326 | is_old_map = 1; | 320 | is_old_map = 1; |
327 | #ifdef GIO_UNISCRNMAP | 321 | #ifdef GIO_UNISCRNMAP |
328 | } | 322 | } |
@@ -332,14 +326,11 @@ void saveoldmap(int fd, char *omfil) | |||
332 | #ifdef GIO_UNISCRNMAP | 326 | #ifdef GIO_UNISCRNMAP |
333 | if (is_old_map) { | 327 | if (is_old_map) { |
334 | #endif | 328 | #endif |
335 | if (fwrite(buf, E_TABSZ, 1, fp) != 1) { | 329 | if (fwrite(buf, E_TABSZ, 1, fp) != 1) |
336 | perror("Error writing map to file"); | 330 | perror_msg_and_die("Error writing map to file"); |
337 | exit(1); | ||
338 | } | ||
339 | #ifdef GIO_UNISCRNMAP | 331 | #ifdef GIO_UNISCRNMAP |
340 | } else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) { | 332 | } else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) { |
341 | perror("Error writing map to file"); | 333 | perror_msg_and_die("Error writing map to file"); |
342 | exit(1); | ||
343 | } | 334 | } |
344 | #endif | 335 | #endif |
345 | 336 | ||