Commit 135610f7 authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

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: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent fbee6b21
...@@ -72,7 +72,7 @@ static void ap_display_usage(void); ...@@ -72,7 +72,7 @@ static void ap_display_usage(void);
static int ap_do_options(int argc, char **argv); static int ap_do_options(int argc, char **argv);
static void ap_insert_action(char *argument, u32 to_be_done); static int ap_insert_action(char *argument, u32 to_be_done);
/* Table for deferred actions from command line options */ /* Table for deferred actions from command line options */
...@@ -124,13 +124,13 @@ static void ap_display_usage(void) ...@@ -124,13 +124,13 @@ static void ap_display_usage(void)
* PARAMETERS: argument - Pointer to the argument for this action * PARAMETERS: argument - Pointer to the argument for this action
* to_be_done - What to do to process this action * to_be_done - What to do to process this action
* *
* RETURN: None. Exits program if action table becomes full. * RETURN: Status
* *
* DESCRIPTION: Add an action item to the action table * DESCRIPTION: Add an action item to the action table
* *
******************************************************************************/ ******************************************************************************/
static void ap_insert_action(char *argument, u32 to_be_done) static int ap_insert_action(char *argument, u32 to_be_done)
{ {
/* Insert action and check for table overflow */ /* Insert action and check for table overflow */
...@@ -142,8 +142,10 @@ static void ap_insert_action(char *argument, u32 to_be_done) ...@@ -142,8 +142,10 @@ static void ap_insert_action(char *argument, u32 to_be_done)
if (current_action > AP_MAX_ACTIONS) { if (current_action > AP_MAX_ACTIONS) {
fprintf(stderr, "Too many table options (max %u)\n", fprintf(stderr, "Too many table options (max %u)\n",
AP_MAX_ACTIONS); AP_MAX_ACTIONS);
exit(-1); return (-1);
} }
return (0);
} }
/****************************************************************************** /******************************************************************************
...@@ -186,12 +188,12 @@ static int ap_do_options(int argc, char **argv) ...@@ -186,12 +188,12 @@ static int ap_do_options(int argc, char **argv)
case '?': case '?':
ap_display_usage(); ap_display_usage();
exit(0); return (1);
case 'o': /* Redirect output to a single file */ case 'o': /* Redirect output to a single file */
if (ap_open_output_file(acpi_gbl_optarg)) { if (ap_open_output_file(acpi_gbl_optarg)) {
exit(-1); return (-1);
} }
continue; continue;
...@@ -204,7 +206,7 @@ static int ap_do_options(int argc, char **argv) ...@@ -204,7 +206,7 @@ static int ap_do_options(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"%s: Could not convert to a physical address\n", "%s: Could not convert to a physical address\n",
acpi_gbl_optarg); acpi_gbl_optarg);
exit(-1); return (-1);
} }
continue; continue;
...@@ -225,7 +227,7 @@ static int ap_do_options(int argc, char **argv) ...@@ -225,7 +227,7 @@ static int ap_do_options(int argc, char **argv)
case 'v': /* Revision/version */ case 'v': /* Revision/version */
printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
exit(0); return (1);
case 'z': /* Verbose mode */ case 'z': /* Verbose mode */
...@@ -238,32 +240,40 @@ static int ap_do_options(int argc, char **argv) ...@@ -238,32 +240,40 @@ static int ap_do_options(int argc, char **argv)
*/ */
case 'a': /* Get table by physical address */ case 'a': /* Get table by physical address */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_ADDRESS); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_ADDRESS)) {
return (-1);
}
break; break;
case 'f': /* Get table from a file */ case 'f': /* Get table from a file */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_FILE); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_FILE)) {
return (-1);
}
break; break;
case 'n': /* Get table by input name (signature) */ case 'n': /* Get table by input name (signature) */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_NAME); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_NAME)) {
return (-1);
}
break; break;
default: default:
ap_display_usage(); ap_display_usage();
exit(-1); return (-1);
} }
/* If there are no actions, this means "get/dump all tables" */ /* If there are no actions, this means "get/dump all tables" */
if (current_action == 0) { if (current_action == 0) {
ap_insert_action(NULL, AP_DUMP_ALL_TABLES); if (ap_insert_action(NULL, AP_DUMP_ALL_TABLES)) {
return (-1);
}
} }
return (0); return (0);
...@@ -293,8 +303,12 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) ...@@ -293,8 +303,12 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
/* Process command line options */ /* Process command line options */
if (ap_do_options(argc, argv)) { status = ap_do_options(argc, argv);
return (-1); if (status > 0) {
return (0);
}
if (status < 0) {
return (status);
} }
/* Get/dump ACPI table(s) as requested */ /* Get/dump ACPI table(s) as requested */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment