OSDN Git Service

staging: speakup: i18n.c: Change return type from int to bool
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Thu, 9 Mar 2017 22:53:23 +0000 (00:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 14:27:45 +0000 (15:27 +0100)
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: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/i18n.c

index ac1ebea..a8326db 100644 (file)
@@ -476,19 +476,20 @@ static char *find_specifier_end(char *input)
 /*
  * Function: compare_specifiers
  * Compare the format specifiers pointed to by *input1 and *input2.
- * Return 1 if they are the same, 0 otherwise.  Advance *input1 and *input2
- * so that they point to the character following the end of the specifier.
+ * Return true if they are the same, false otherwise.
+ * 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 *end2 = find_specifier_end(*input2);
        size_t length1 = end1 - *input1;
        size_t length2 = end2 - *input2;
 
        if ((length1 == length2) && !memcmp(*input1, *input2, length1))
-               same = 1;
+               same = true;
 
        *input1 = end1;
        *input2 = end2;
@@ -499,12 +500,12 @@ static int compare_specifiers(char **input1, char **input2)
  * Function: fmt_validate
  * Check that two format strings contain the same number of format specifiers,
  * 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;
-       int still_comparing = 1;
+       bool valid = true;
+       bool still_comparing = true;
        char *template_ptr = template;
        char *user_ptr = user;
 
@@ -516,10 +517,10 @@ static int fmt_validate(char *template, char *user)
                        valid = compare_specifiers(&template_ptr, &user_ptr);
                } else {
                        /* No more format specifiers in one or both strings. */
-                       still_comparing = 0;
+                       still_comparing = false;
                        /* See if one has more specifiers than the other. */
                        if (template_ptr || user_ptr)
-                               valid = 0;
+                               valid = false;
                }
        }
        return valid;