Просмотр исходного кода

u-a: Do not use trinary boolean operators with explicit bool result values

Use explicit checks for the value we expect and just return the
result of the boolean evaluation, or return explicitly from an
unary conditional check.
Guillem Jover лет назад: 14
Родитель
Сommit
a31e40a55a
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      utils/update-alternatives.c

+ 5 - 5
utils/update-alternatives.c

@@ -667,7 +667,6 @@ static bool
 fileset_can_install_slave(struct fileset *fs, const char *slave_name)
 fileset_can_install_slave(struct fileset *fs, const char *slave_name)
 {
 {
 	struct stat st;
 	struct stat st;
-	bool install_slave = false;
 
 
 	/* Decide whether the slave alternative must be setup */
 	/* Decide whether the slave alternative must be setup */
 	if (fileset_has_slave(fs, slave_name)) {
 	if (fileset_has_slave(fs, slave_name)) {
@@ -676,10 +675,11 @@ fileset_can_install_slave(struct fileset *fs, const char *slave_name)
 		errno = 0;
 		errno = 0;
 		if (stat(slave, &st) == -1 && errno != ENOENT)
 		if (stat(slave, &st) == -1 && errno != ENOENT)
 			syserr(_("cannot stat file '%s'"), slave);
 			syserr(_("cannot stat file '%s'"), slave);
-		install_slave = (errno == 0) ? true : false;
+		if (errno == 0)
+			return true;
 	}
 	}
 
 
-	return install_slave;
+	return false;
 }
 }
 
 
 struct slave_link {
 struct slave_link {
@@ -948,13 +948,13 @@ alternative_get_slave(struct alternative *a, const char *name)
 static bool
 static bool
 alternative_has_slave(struct alternative *a, const char *name)
 alternative_has_slave(struct alternative *a, const char *name)
 {
 {
-	return alternative_get_slave(a, name) ? true : false;
+	return alternative_get_slave(a, name) != NULL;
 }
 }
 
 
 static bool
 static bool
 alternative_has_choice(struct alternative *a, const char *file)
 alternative_has_choice(struct alternative *a, const char *file)
 {
 {
-	return alternative_get_fileset(a, file) ? true : false;
+	return alternative_get_fileset(a, file) != NULL;
 }
 }
 
 
 static void
 static void