Remove superfluous casts

-  Every non-const pointer converts automatically to void *.
-  Every pointer converts automatically to void *.
-  void * converts to any other pointer.
-  const void * converts to any other const pointer.
-  Integer variables convert to each other.

I changed the declaration of a few variables in order to allow removing
a cast.

However, I didn't attempt to edit casts inside comparisons, since they
are very delicate.  I also kept casts in variadic functions, since they
are necessary, and in allocation functions, because I have other plans
for them.

I also changed a few casts to int that are better as ptrdiff_t.

This change has triggered some warnings about const correctness issues,
which have also been fixed in this patch (see for example src/login.c).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-02-01 13:50:48 +01:00
committed by Serge Hallyn
parent 66daa74232
commit bddcd9b095
62 changed files with 260 additions and 319 deletions

View File

@@ -22,7 +22,7 @@
*/
void cleanup_report_add_user (void *user_name)
{
const char *name = (const char *)user_name;
const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s", name));
#ifdef WITH_AUDIT
@@ -59,7 +59,7 @@ void cleanup_report_mod_passwd (void *cleanup_info)
*/
void cleanup_report_add_user_passwd (void *user_name)
{
const char *name = (const char *)user_name;
const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, pw_dbname ()));
#ifdef WITH_AUDIT
@@ -79,7 +79,7 @@ void cleanup_report_add_user_passwd (void *user_name)
*/
void cleanup_report_add_user_shadow (void *user_name)
{
const char *name = (const char *)user_name;
const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, spw_dbname ()));
#ifdef WITH_AUDIT