diff options
author | Lv Zheng <lv.zheng@intel.com> | 2014-07-07 22:07:39 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-07-08 08:22:27 -0400 |
commit | 135610f792addb71af7be0e00aa7486429bf7a37 (patch) | |
tree | b7dc28c97f7f5a36bbbad9ab4e373863e4a2957e /tools | |
parent | fbee6b21a3820a55ec36a2aceb138f3973a955ac (diff) |
ACPICA: acpidump: Remove exit() from generic layer to improve portability
This patch removes exit() from generic acpidump code to improve the
portability of this tool. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/acpi/tools/acpidump/apmain.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c index 9c3b259aed2c..55fd44d5f2e8 100644 --- a/tools/power/acpi/tools/acpidump/apmain.c +++ b/tools/power/acpi/tools/acpidump/apmain.c | |||
@@ -72,7 +72,7 @@ static void ap_display_usage(void); | |||
72 | 72 | ||
73 | static int ap_do_options(int argc, char **argv); | 73 | static int ap_do_options(int argc, char **argv); |
74 | 74 | ||
75 | static void ap_insert_action(char *argument, u32 to_be_done); | 75 | static int ap_insert_action(char *argument, u32 to_be_done); |
76 | 76 | ||
77 | /* Table for deferred actions from command line options */ | 77 | /* Table for deferred actions from command line options */ |
78 | 78 | ||
@@ -124,13 +124,13 @@ static void ap_display_usage(void) | |||
124 | * PARAMETERS: argument - Pointer to the argument for this action | 124 | * PARAMETERS: argument - Pointer to the argument for this action |
125 | * to_be_done - What to do to process this action | 125 | * to_be_done - What to do to process this action |
126 | * | 126 | * |
127 | * RETURN: None. Exits program if action table becomes full. | 127 | * RETURN: Status |
128 | * | 128 | * |
129 | * DESCRIPTION: Add an action item to the action table | 129 | * DESCRIPTION: Add an action item to the action table |
130 | * | 130 | * |
131 | ******************************************************************************/ | 131 | ******************************************************************************/ |
132 | 132 | ||
133 | static void ap_insert_action(char *argument, u32 to_be_done) | 133 | static int ap_insert_action(char *argument, u32 to_be_done) |
134 | { | 134 | { |
135 | 135 | ||
136 | /* Insert action and check for table overflow */ | 136 | /* Insert action and check for table overflow */ |
@@ -142,8 +142,10 @@ static void ap_insert_action(char *argument, u32 to_be_done) | |||
142 | if (current_action > AP_MAX_ACTIONS) { | 142 | if (current_action > AP_MAX_ACTIONS) { |
143 | fprintf(stderr, "Too many table options (max %u)\n", | 143 | fprintf(stderr, "Too many table options (max %u)\n", |
144 | AP_MAX_ACTIONS); | 144 | AP_MAX_ACTIONS); |
145 | exit(-1); | 145 | return (-1); |
146 | } | 146 | } |
147 | |||
148 | return (0); | ||
147 | } | 149 | } |
148 | 150 | ||
149 | /****************************************************************************** | 151 | /****************************************************************************** |
@@ -186,12 +188,12 @@ static int ap_do_options(int argc, char **argv) | |||
186 | case '?': | 188 | case '?': |
187 | 189 | ||
188 | ap_display_usage(); | 190 | ap_display_usage(); |
189 | exit(0); | 191 | return (1); |
190 | 192 | ||
191 | case 'o': /* Redirect output to a single file */ | 193 | case 'o': /* Redirect output to a single file */ |
192 | 194 | ||
193 | if (ap_open_output_file(acpi_gbl_optarg)) { | 195 | if (ap_open_output_file(acpi_gbl_optarg)) { |
194 | exit(-1); | 196 | return (-1); |
195 | } | 197 | } |
196 | continue; | 198 | continue; |
197 | 199 | ||
@@ -204,7 +206,7 @@ static int ap_do_options(int argc, char **argv) | |||
204 | fprintf(stderr, | 206 | fprintf(stderr, |
205 | "%s: Could not convert to a physical address\n", | 207 | "%s: Could not convert to a physical address\n", |
206 | acpi_gbl_optarg); | 208 | acpi_gbl_optarg); |
207 | exit(-1); | 209 | return (-1); |
208 | } | 210 | } |
209 | continue; | 211 | continue; |
210 | 212 | ||
@@ -225,7 +227,7 @@ static int ap_do_options(int argc, char **argv) | |||
225 | case 'v': /* Revision/version */ | 227 | case 'v': /* Revision/version */ |
226 | 228 | ||
227 | printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); | 229 | printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); |
228 | exit(0); | 230 | return (1); |
229 | 231 | ||
230 | case 'z': /* Verbose mode */ | 232 | case 'z': /* Verbose mode */ |
231 | 233 | ||
@@ -238,32 +240,40 @@ static int ap_do_options(int argc, char **argv) | |||
238 | */ | 240 | */ |
239 | case 'a': /* Get table by physical address */ | 241 | case 'a': /* Get table by physical address */ |
240 | 242 | ||
241 | ap_insert_action(acpi_gbl_optarg, | 243 | if (ap_insert_action |
242 | AP_DUMP_TABLE_BY_ADDRESS); | 244 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_ADDRESS)) { |
245 | return (-1); | ||
246 | } | ||
243 | break; | 247 | break; |
244 | 248 | ||
245 | case 'f': /* Get table from a file */ | 249 | case 'f': /* Get table from a file */ |
246 | 250 | ||
247 | ap_insert_action(acpi_gbl_optarg, | 251 | if (ap_insert_action |
248 | AP_DUMP_TABLE_BY_FILE); | 252 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_FILE)) { |
253 | return (-1); | ||
254 | } | ||
249 | break; | 255 | break; |
250 | 256 | ||
251 | case 'n': /* Get table by input name (signature) */ | 257 | case 'n': /* Get table by input name (signature) */ |
252 | 258 | ||
253 | ap_insert_action(acpi_gbl_optarg, | 259 | if (ap_insert_action |
254 | AP_DUMP_TABLE_BY_NAME); | 260 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_NAME)) { |
261 | return (-1); | ||
262 | } | ||
255 | break; | 263 | break; |
256 | 264 | ||
257 | default: | 265 | default: |
258 | 266 | ||
259 | ap_display_usage(); | 267 | ap_display_usage(); |
260 | exit(-1); | 268 | return (-1); |
261 | } | 269 | } |
262 | 270 | ||
263 | /* If there are no actions, this means "get/dump all tables" */ | 271 | /* If there are no actions, this means "get/dump all tables" */ |
264 | 272 | ||
265 | if (current_action == 0) { | 273 | if (current_action == 0) { |
266 | ap_insert_action(NULL, AP_DUMP_ALL_TABLES); | 274 | if (ap_insert_action(NULL, AP_DUMP_ALL_TABLES)) { |
275 | return (-1); | ||
276 | } | ||
267 | } | 277 | } |
268 | 278 | ||
269 | return (0); | 279 | return (0); |
@@ -293,8 +303,12 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) | |||
293 | 303 | ||
294 | /* Process command line options */ | 304 | /* Process command line options */ |
295 | 305 | ||
296 | if (ap_do_options(argc, argv)) { | 306 | status = ap_do_options(argc, argv); |
297 | return (-1); | 307 | if (status > 0) { |
308 | return (0); | ||
309 | } | ||
310 | if (status < 0) { | ||
311 | return (status); | ||
298 | } | 312 | } |
299 | 313 | ||
300 | /* Get/dump ACPI table(s) as requested */ | 314 | /* Get/dump ACPI table(s) as requested */ |