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-29 17:00:02 -04:00
parent 8127947b30
commit 26de917c7a

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
* by the MIT license.
*
* Author: Daniel Reinhold (danielre@users.sf.net)
* Authors:
* Daniel Reinhold, danielre@users.sf.net
*/
/** 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <OS.h>
static status_t
@ -25,20 +24,23 @@ list_images_for_team_by_id(team_id id)
team_info teamInfo;
image_info imageInfo;
int32 cookie = 0;
status_t status;
status_t result;
status = get_team_info(id, &teamInfo);
if (id != 1 && status < B_OK)
return status;
result = get_team_info(id, &teamInfo);
if (id != 1 && result < B_OK)
return result;
if (id == 1)
printf("\nKERNEL TEAM:\n");
else
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",
imageInfo.id,
imageInfo.name,
@ -47,40 +49,41 @@ list_images_for_team_by_id(team_id id)
imageInfo.sequence,
imageInfo.init_order);
}
if (status != B_ENTRY_NOT_FOUND && status != EINVAL) {
printf("get images failed: %s\n", strerror(status));
return status;
if (result != B_ENTRY_NOT_FOUND && result != EINVAL) {
printf("get images failed: %s\n", strerror(result));
return result;
}
return B_OK;
}
static void
list_images_for_team(const char *arg)
list_images_for_team(const char* arg)
{
int32 cookie = 0;
team_info info;
if (atoi(arg) > 0) {
if (list_images_for_team_by_id(atoi(arg)) == B_OK)
return;
}
if (atoi(arg) > 0 && list_images_for_team_by_id(atoi(arg)) == B_OK)
return;
// search for the team by name
while (get_next_team_info(&cookie, &info) >= B_OK) {
if (strstr(info.args, arg)) {
status_t status = list_images_for_team_by_id(info.team);
if (status != B_OK)
status_t result = list_images_for_team_by_id(info.team);
if (result != B_OK) {
printf("\nCould not retrieve information about team %ld: %s\n",
info.team, strerror(status));
info.team, strerror(result));
}
}
}
}
int
main(int argc, char **argv)
main(int argc, char** argv)
{
if (argc == 1) {
int32 cookie = 0;
@ -88,16 +91,17 @@ main(int argc, char **argv)
// list for all teams
while (get_next_team_info(&cookie, &info) >= B_OK) {
status_t status = list_images_for_team_by_id(info.team);
if (status != B_OK)
status_t result = list_images_for_team_by_id(info.team);
if (result != B_OK) {
printf("\nCould not retrieve information about team %ld: %s\n",
info.team, strerror(status));
info.team, strerror(result));
}
}
} else {
// list for each team_id on the command line
while (--argc)
list_images_for_team(*++argv);
}
return 0;
}