Prefer other types to int in map.c

* src/map.c (map_read): Prefer bool for booleans.
(owner_map_translate, group_map_translate):
Return void, not int, as nobody uses the return value.
This commit is contained in:
Paul Eggert
2024-11-01 18:51:05 -07:00
parent 91ad4ea343
commit 53a3691092
2 changed files with 17 additions and 37 deletions

View File

@@ -1060,9 +1060,9 @@ void exclude_vcs_ignores (void);
/* Module map.c */
void owner_map_read (char const *name);
int owner_map_translate (uid_t uid, uid_t *new_uid, char const **new_name);
void owner_map_translate (uid_t uid, uid_t *new_uid, char const **new_name);
void group_map_read (char const *file);
int group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name);
void group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name);
_GL_INLINE_HEADER_END

View File

@@ -79,7 +79,7 @@ map_read (Hash_table **ptab, char const *file,
struct wordsplit ws;
int wsopt;
intmax_t line;
int err = 0;
bool err = false;
fp = fopen (file, "r");
if (!fp)
@@ -106,7 +106,7 @@ map_read (Hash_table **ptab, char const *file,
if (ws.ws_wordc != 2)
{
error (0, 0, _("%s:%jd: malformed line"), file, line);
err = 1;
err = true;
continue;
}
@@ -114,7 +114,7 @@ map_read (Hash_table **ptab, char const *file,
{
if (!parse_id (&orig_id, ws.ws_wordv[0]+1, what, maxval, file, line))
{
err = 1;
err = true;
continue;
}
}
@@ -125,7 +125,7 @@ map_read (Hash_table **ptab, char const *file,
{
error (0, 0, _("%s:%jd: can't obtain %s of %s"),
file, line, what, ws.ws_wordv[0]);
err = 1;
err = true;
continue;
}
}
@@ -138,7 +138,7 @@ map_read (Hash_table **ptab, char const *file,
*colon++ = 0;
if (!parse_id (&new_id, colon, what, maxval, file, line))
{
err = 1;
err = true;
continue;
}
}
@@ -146,7 +146,7 @@ map_read (Hash_table **ptab, char const *file,
{
if (!parse_id (&new_id, ws.ws_wordv[1], what, maxval, file, line))
{
err = 1;
err = true;
continue;
}
}
@@ -158,7 +158,7 @@ map_read (Hash_table **ptab, char const *file,
{
error (0, 0, _("%s:%jd: can't obtain %s of %s"),
file, line, what, ws.ws_wordv[1]);
err = 1;
err = true;
continue;
}
}
@@ -197,11 +197,9 @@ owner_map_read (char const *file)
map_read (&owner_map, file, name_to_uid, "UID", TYPE_MAXIMUM (uid_t));
}
int
void
owner_map_translate (uid_t uid, uid_t *new_uid, char const **new_name)
{
int rc = 1;
if (owner_map)
{
struct mapentry ent, *res;
@@ -212,23 +210,15 @@ owner_map_translate (uid_t uid, uid_t *new_uid, char const **new_name)
{
*new_uid = res->new_id;
*new_name = res->new_name;
return 0;
return;
}
}
uid_t minus_1 = -1;
if (owner_option != minus_1)
{
*new_uid = owner_option;
rc = 0;
}
*new_uid = owner_option;
if (owner_name_option)
{
*new_name = owner_name_option;
rc = 0;
}
return rc;
*new_name = owner_name_option;
}
/* GID translation */
@@ -248,11 +238,9 @@ group_map_read (char const *file)
map_read (&group_map, file, name_to_gid, "GID", TYPE_MAXIMUM (gid_t));
}
int
void
group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name)
{
int rc = 1;
if (group_map)
{
struct mapentry ent, *res;
@@ -263,21 +251,13 @@ group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name)
{
*new_gid = res->new_id;
*new_name = res->new_name;
return 0;
return;
}
}
gid_t minus_1 = -1;
if (group_option != minus_1)
{
*new_gid = group_option;
rc = 0;
}
*new_gid = group_option;
if (group_name_option)
{
*new_name = group_name_option;
rc = 0;
}
return rc;
*new_name = group_name_option;
}