Commit eaeab71f authored by Narcisa Ana Maria Vasile's avatar Narcisa Ana Maria Vasile Committed by Greg Kroah-Hartman

staging: speakup: i18n.c: Change return type from int to bool

The possible return values (0 or 1) for compare_specifiers
and fmt_validate represent whether a condition holds or not, so
conceptually, they are booleans.

Update documentation for these two functions.

Change type of variable 'still_comparing' from int to bool too,
inside fmt_validate, because it is intended to hold truth values
as well.
Signed-off-by: default avatarNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 37c00229
...@@ -476,19 +476,20 @@ static char *find_specifier_end(char *input) ...@@ -476,19 +476,20 @@ static char *find_specifier_end(char *input)
/* /*
* Function: compare_specifiers * Function: compare_specifiers
* Compare the format specifiers pointed to by *input1 and *input2. * Compare the format specifiers pointed to by *input1 and *input2.
* Return 1 if they are the same, 0 otherwise. Advance *input1 and *input2 * Return true if they are the same, false otherwise.
* so that they point to the character following the end of the specifier. * Advance *input1 and *input2 so that they point to the character following
* the end of the specifier.
*/ */
static int compare_specifiers(char **input1, char **input2) static bool compare_specifiers(char **input1, char **input2)
{ {
int same = 0; bool same = false;
char *end1 = find_specifier_end(*input1); char *end1 = find_specifier_end(*input1);
char *end2 = find_specifier_end(*input2); char *end2 = find_specifier_end(*input2);
size_t length1 = end1 - *input1; size_t length1 = end1 - *input1;
size_t length2 = end2 - *input2; size_t length2 = end2 - *input2;
if ((length1 == length2) && !memcmp(*input1, *input2, length1)) if ((length1 == length2) && !memcmp(*input1, *input2, length1))
same = 1; same = true;
*input1 = end1; *input1 = end1;
*input2 = end2; *input2 = end2;
...@@ -499,12 +500,12 @@ static int compare_specifiers(char **input1, char **input2) ...@@ -499,12 +500,12 @@ static int compare_specifiers(char **input1, char **input2)
* Function: fmt_validate * Function: fmt_validate
* Check that two format strings contain the same number of format specifiers, * Check that two format strings contain the same number of format specifiers,
* and that the order of specifiers is the same in both strings. * and that the order of specifiers is the same in both strings.
* Return 1 if the condition holds, 0 if it doesn't. * Return true if the condition holds, false if it doesn't.
*/ */
static int fmt_validate(char *template, char *user) static bool fmt_validate(char *template, char *user)
{ {
int valid = 1; bool valid = true;
int still_comparing = 1; bool still_comparing = true;
char *template_ptr = template; char *template_ptr = template;
char *user_ptr = user; char *user_ptr = user;
...@@ -516,10 +517,10 @@ static int fmt_validate(char *template, char *user) ...@@ -516,10 +517,10 @@ static int fmt_validate(char *template, char *user)
valid = compare_specifiers(&template_ptr, &user_ptr); valid = compare_specifiers(&template_ptr, &user_ptr);
} else { } else {
/* No more format specifiers in one or both strings. */ /* No more format specifiers in one or both strings. */
still_comparing = 0; still_comparing = false;
/* See if one has more specifiers than the other. */ /* See if one has more specifiers than the other. */
if (template_ptr || user_ptr) if (template_ptr || user_ptr)
valid = 0; valid = false;
} }
} }
return valid; return valid;
......
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