listimage: style fixes

Also use puts() in place of printf() in a couple places
where no string interpolation takes place.

Replace the variable name "status" with "result", I just like
it better that way for easier grep-ability.
This commit is contained in:
John Scipione
2014-06-30 00:22:28 -04:00
parent 8127947b30
commit 26de917c7a
+33 -29
View File
@@ -1,22 +1,21 @@
/* /*
* Copyright (c) 2001-2005, Haiku. * Copyright (c) 2001-2005 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
* *
* This software is part of the Haiku distribution and is covered * Authors:
* by the MIT license. * Daniel Reinhold, [email protected]
*
* Author: Daniel Reinhold ([email protected])
*/ */
/** Description: lists image info for all currently running teams */ /*! Lists image info for all currently running teams. */
#include <OS.h> #include <ctype.h>
#include <image.h> #include <image.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <OS.h>
static status_t static status_t
@@ -25,20 +24,23 @@ list_images_for_team_by_id(team_id id)
team_info teamInfo; team_info teamInfo;
image_info imageInfo; image_info imageInfo;
int32 cookie = 0; int32 cookie = 0;
status_t status; status_t result;
status = get_team_info(id, &teamInfo); result = get_team_info(id, &teamInfo);
if (id != 1 && status < B_OK) if (id != 1 && result < B_OK)
return status; return result;
if (id == 1) if (id == 1)
printf("\nKERNEL TEAM:\n"); printf("\nKERNEL TEAM:\n");
else else
printf("\nTEAM %4ld (%s):\n", id, teamInfo.args); printf("\nTEAM %4ld (%s):\n", id, teamInfo.args);
printf(" ID name text data seq# init#\n");
printf("------------------------------------------------------------------------------------------------------------\n");
while ((status = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) { puts(" ID name"
" text data seq# init#");
puts("---------------------------------------------------------------------"
"---------------------------------------");
while ((result = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) {
printf("%5ld %64s %p %p %4ld %10lu\n", printf("%5ld %64s %p %p %4ld %10lu\n",
imageInfo.id, imageInfo.id,
imageInfo.name, imageInfo.name,
@@ -47,10 +49,12 @@ list_images_for_team_by_id(team_id id)
imageInfo.sequence, imageInfo.sequence,
imageInfo.init_order); imageInfo.init_order);
} }
if (status != B_ENTRY_NOT_FOUND && status != EINVAL) {
printf("get images failed: %s\n", strerror(status)); if (result != B_ENTRY_NOT_FOUND && result != EINVAL) {
return status; printf("get images failed: %s\n", strerror(result));
return result;
} }
return B_OK; return B_OK;
} }
@@ -61,19 +65,18 @@ list_images_for_team(const char *arg)
int32 cookie = 0; int32 cookie = 0;
team_info info; team_info info;
if (atoi(arg) > 0) { if (atoi(arg) > 0 && list_images_for_team_by_id(atoi(arg)) == B_OK)
if (list_images_for_team_by_id(atoi(arg)) == B_OK)
return; return;
}
// search for the team by name // search for the team by name
while (get_next_team_info(&cookie, &info) >= B_OK) { while (get_next_team_info(&cookie, &info) >= B_OK) {
if (strstr(info.args, arg)) { if (strstr(info.args, arg)) {
status_t status = list_images_for_team_by_id(info.team); status_t result = list_images_for_team_by_id(info.team);
if (status != B_OK) if (result != B_OK) {
printf("\nCould not retrieve information about team %ld: %s\n", printf("\nCould not retrieve information about team %ld: %s\n",
info.team, strerror(status)); info.team, strerror(result));
}
} }
} }
} }
@@ -88,16 +91,17 @@ main(int argc, char **argv)
// list for all teams // list for all teams
while (get_next_team_info(&cookie, &info) >= B_OK) { while (get_next_team_info(&cookie, &info) >= B_OK) {
status_t status = list_images_for_team_by_id(info.team); status_t result = list_images_for_team_by_id(info.team);
if (status != B_OK) if (result != B_OK) {
printf("\nCould not retrieve information about team %ld: %s\n", printf("\nCould not retrieve information about team %ld: %s\n",
info.team, strerror(status)); info.team, strerror(result));
}
} }
} else { } else {
// list for each team_id on the command line // list for each team_id on the command line
while (--argc) while (--argc)
list_images_for_team(*++argv); list_images_for_team(*++argv);
} }
return 0; return 0;
} }