Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Narcisa Ana Maria Vasile and committed by
Greg Kroah-Hartman
eaeab71f 37c00229

+12 -11
+12 -11
drivers/staging/speakup/i18n.c
··· 476 476 /* 477 477 * Function: compare_specifiers 478 478 * Compare the format specifiers pointed to by *input1 and *input2. 479 - * Return 1 if they are the same, 0 otherwise. Advance *input1 and *input2 480 - * so that they point to the character following the end of the specifier. 479 + * Return true if they are the same, false otherwise. 480 + * Advance *input1 and *input2 so that they point to the character following 481 + * the end of the specifier. 481 482 */ 482 - static int compare_specifiers(char **input1, char **input2) 483 + static bool compare_specifiers(char **input1, char **input2) 483 484 { 484 - int same = 0; 485 + bool same = false; 485 486 char *end1 = find_specifier_end(*input1); 486 487 char *end2 = find_specifier_end(*input2); 487 488 size_t length1 = end1 - *input1; 488 489 size_t length2 = end2 - *input2; 489 490 490 491 if ((length1 == length2) && !memcmp(*input1, *input2, length1)) 491 - same = 1; 492 + same = true; 492 493 493 494 *input1 = end1; 494 495 *input2 = end2; ··· 500 499 * Function: fmt_validate 501 500 * Check that two format strings contain the same number of format specifiers, 502 501 * and that the order of specifiers is the same in both strings. 503 - * Return 1 if the condition holds, 0 if it doesn't. 502 + * Return true if the condition holds, false if it doesn't. 504 503 */ 505 - static int fmt_validate(char *template, char *user) 504 + static bool fmt_validate(char *template, char *user) 506 505 { 507 - int valid = 1; 508 - int still_comparing = 1; 506 + bool valid = true; 507 + bool still_comparing = true; 509 508 char *template_ptr = template; 510 509 char *user_ptr = user; 511 510 ··· 517 516 valid = compare_specifiers(&template_ptr, &user_ptr); 518 517 } else { 519 518 /* No more format specifiers in one or both strings. */ 520 - still_comparing = 0; 519 + still_comparing = false; 521 520 /* See if one has more specifiers than the other. */ 522 521 if (template_ptr || user_ptr) 523 - valid = 0; 522 + valid = false; 524 523 } 525 524 } 526 525 return valid;