lib: Make check_enable_color() return boolean

As suggested, turn return code into true/false although it's not checked
anywhere yet.

Fixes: 4d82962ccc ("Merge common code for conditionally colored output")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Phil Sutter 2018-08-17 18:38:46 +02:00 committed by Stephen Hemminger
parent ff1ab8edf8
commit 515a766cd2
2 changed files with 5 additions and 5 deletions

View File

@ -21,7 +21,7 @@ enum color_opt {
};
void enable_color(void);
int check_enable_color(int color, int json);
bool check_enable_color(int color, int json);
bool matches_color(const char *arg, int *val);
void set_color_palette(void);
int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);

View File

@ -79,16 +79,16 @@ void enable_color(void)
set_color_palette();
}
int check_enable_color(int color, int json)
bool check_enable_color(int color, int json)
{
if (json || color == COLOR_OPT_NEVER)
return 1;
return false;
if (color == COLOR_OPT_ALWAYS || isatty(fileno(stdout))) {
enable_color();
return 0;
return true;
}
return 1;
return false;
}
bool matches_color(const char *arg, int *val)