mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
This commit is contained in:
parent
4421d98e30
commit
765936ebae
103 changed files with 219 additions and 362 deletions
|
@ -41,7 +41,7 @@ __attribute__((noreturn)) void __assertion_failed(const char* msg);
|
|||
} while (0)
|
||||
# define ASSERT_NOT_REACHED() assert(false)
|
||||
#else
|
||||
# define assert(expr) ((void)0)
|
||||
# define assert(expr) (void(0))
|
||||
# define ASSERT_NOT_REACHED() CRASH()
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,15 +36,13 @@ int sched_yield()
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int sched_get_priority_min(int policy)
|
||||
int sched_get_priority_min([[maybe_unused]] int policy)
|
||||
{
|
||||
(void)policy;
|
||||
return 0; // Idle
|
||||
}
|
||||
|
||||
int sched_get_priority_max(int policy)
|
||||
int sched_get_priority_max([[maybe_unused]] int policy)
|
||||
{
|
||||
(void)policy;
|
||||
return 3; // High
|
||||
}
|
||||
|
||||
|
|
|
@ -1179,15 +1179,13 @@ int vfscanf(FILE* stream, const char* fmt, va_list ap)
|
|||
return vsscanf(buffer, fmt, ap);
|
||||
}
|
||||
|
||||
void flockfile(FILE* filehandle)
|
||||
void flockfile([[maybe_unused]] FILE* filehandle)
|
||||
{
|
||||
(void)filehandle;
|
||||
dbgprintf("FIXME: Implement flockfile()\n");
|
||||
}
|
||||
|
||||
void funlockfile(FILE* filehandle)
|
||||
void funlockfile([[maybe_unused]] FILE* filehandle)
|
||||
{
|
||||
(void)filehandle;
|
||||
dbgprintf("FIXME: Implement funlockfile()\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -804,11 +804,9 @@ size_t mbstowcs(wchar_t*, const char*, size_t)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
int mbtowc(wchar_t* wch, const char* data, size_t data_size)
|
||||
int mbtowc(wchar_t* wch, const char* data, [[maybe_unused]] size_t data_size)
|
||||
{
|
||||
// FIXME: This needs a real implementation.
|
||||
UNUSED_PARAM(data_size);
|
||||
|
||||
if (wch && data) {
|
||||
*wch = *data;
|
||||
return 1;
|
||||
|
@ -1023,7 +1021,7 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
|
|||
// Serenity's PRNG is not cryptographically secure. Do not rely on this for
|
||||
// any real crypto! These functions (for now) are for compatibility.
|
||||
// TODO: In the future, rand can be made deterministic and this not.
|
||||
uint32_t arc4random(void)
|
||||
uint32_t arc4random()
|
||||
{
|
||||
char buf[4];
|
||||
syscall(SC_getrandom, buf, 4, 0);
|
||||
|
@ -1073,15 +1071,13 @@ int posix_openpt(int flags)
|
|||
return open("/dev/ptmx", flags);
|
||||
}
|
||||
|
||||
int grantpt(int fd)
|
||||
int grantpt([[maybe_unused]] int fd)
|
||||
{
|
||||
(void)fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unlockpt(int fd)
|
||||
int unlockpt([[maybe_unused]] int fd)
|
||||
{
|
||||
(void)fd;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ __BEGIN_DECLS
|
|||
__attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
|
||||
__attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
|
||||
size_t malloc_size(void*);
|
||||
void serenity_dump_malloc_stats(void);
|
||||
void serenity_dump_malloc_stats();
|
||||
void free(void*);
|
||||
__attribute__((alloc_size(2))) void* realloc(void* ptr, size_t);
|
||||
char* getenv(const char* name);
|
||||
int putenv(char*);
|
||||
int unsetenv(const char*);
|
||||
int clearenv(void);
|
||||
int clearenv();
|
||||
int setenv(const char* name, const char* value, int overwrite);
|
||||
int atoi(const char*);
|
||||
long atol(const char*);
|
||||
|
@ -87,7 +87,7 @@ void srand(unsigned seed);
|
|||
long int random();
|
||||
void srandom(unsigned seed);
|
||||
|
||||
uint32_t arc4random(void);
|
||||
uint32_t arc4random();
|
||||
void arc4random_buf(void*, size_t);
|
||||
uint32_t arc4random_uniform(uint32_t);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void closelog_r(struct syslog_data* data)
|
|||
data->maskpri = LOG_UPTO(LOG_DEBUG);
|
||||
}
|
||||
|
||||
void closelog(void)
|
||||
void closelog()
|
||||
{
|
||||
closelog_r(&global_log_data);
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ struct syslog_data {
|
|||
#define LOG_DAEMON ( 3 << 3)
|
||||
#define LOG_AUTH ( 4 << 3)
|
||||
#define LOG_SYSLOG ( 5 << 3)
|
||||
#define LOG_LPR ( 6 << 3)
|
||||
#define LOG_NEWS ( 7 << 3)
|
||||
#define LOG_LPR ( 6 << 3)
|
||||
#define LOG_NEWS ( 7 << 3)
|
||||
#define LOG_UUCP ( 8 << 3)
|
||||
#define LOG_CRON ( 9 << 3)
|
||||
#define LOG_AUTHPRIV (10 << 3)
|
||||
|
@ -169,7 +169,7 @@ void vsyslog(int, const char* message, va_list);
|
|||
void vsyslog_r(int, struct syslog_data* data, const char* message, va_list);
|
||||
void openlog(const char*, int, int);
|
||||
void openlog_r(const char*, int, int, struct syslog_data*);
|
||||
void closelog(void);
|
||||
void closelog();
|
||||
void closelog_r(struct syslog_data*);
|
||||
int setlogmask(int);
|
||||
int setlogmask_r(int, struct syslog_data*);
|
||||
|
|
|
@ -39,10 +39,8 @@ char PC;
|
|||
char* UP;
|
||||
char* BC;
|
||||
|
||||
int tgetent(char* bp, const char* name)
|
||||
int tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name)
|
||||
{
|
||||
(void)bp;
|
||||
(void)name;
|
||||
#ifdef TERMCAP_DEBUG
|
||||
fprintf(stderr, "tgetent: bp=%p, name='%s'\n", bp, name);
|
||||
#endif
|
||||
|
@ -120,9 +118,8 @@ char* tgetstr(const char* id, char** area)
|
|||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int tgetflag(const char* id)
|
||||
int tgetflag([[maybe_unused]] const char* id)
|
||||
{
|
||||
(void)id;
|
||||
#ifdef TERMCAP_DEBUG
|
||||
fprintf(stderr, "tgetflag: '%s'\n", id);
|
||||
#endif
|
||||
|
@ -143,17 +140,13 @@ int tgetnum(const char* id)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
char* tgoto(const char* cap, int col, int row)
|
||||
char* tgoto([[maybe_unused]] const char* cap, [[maybe_unused]] int col, [[maybe_unused]] int row)
|
||||
{
|
||||
(void)cap;
|
||||
(void)col;
|
||||
(void)row;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
int tputs(const char* str, int affcnt, int (*putc)(int))
|
||||
int tputs(const char* str, [[maybe_unused]] int affcnt, int (*putc)(int))
|
||||
{
|
||||
(void)affcnt;
|
||||
size_t len = strlen(str);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
putc(str[i]);
|
||||
|
|
|
@ -51,10 +51,8 @@ int tcsetattr(int fd, int optional_actions, const struct termios* t)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int tcflow(int fd, int action)
|
||||
int tcflow([[maybe_unused]] int fd, [[maybe_unused]] int action)
|
||||
{
|
||||
(void)fd;
|
||||
(void)action;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,18 +31,14 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
long ulimit(int cmd, long newlimit)
|
||||
long ulimit([[maybe_unused]] int cmd, [[maybe_unused]] long newlimit)
|
||||
{
|
||||
(void)cmd;
|
||||
(void)newlimit;
|
||||
ASSERT_NOT_REACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int getrusage(int who, struct rusage* usage)
|
||||
int getrusage([[maybe_unused]] int who, [[maybe_unused]] struct rusage* usage)
|
||||
{
|
||||
(void)who;
|
||||
(void)usage;
|
||||
dbg() << "LibC: getrusage is not implemented";
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -515,11 +515,8 @@ int mknod(const char* pathname, mode_t mode, dev_t dev)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
long fpathconf(int fd, int name)
|
||||
long fpathconf([[maybe_unused]] int fd, [[maybe_unused]] int name)
|
||||
{
|
||||
(void)fd;
|
||||
(void)name;
|
||||
|
||||
switch (name) {
|
||||
case _PC_PATH_MAX:
|
||||
return PATH_MAX;
|
||||
|
@ -530,10 +527,8 @@ long fpathconf(int fd, int name)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
long pathconf(const char* path, int name)
|
||||
long pathconf([[maybe_unused]] const char* path, int name)
|
||||
{
|
||||
(void)path;
|
||||
|
||||
switch (name) {
|
||||
case _PC_PATH_MAX:
|
||||
return PATH_MAX;
|
||||
|
@ -614,9 +609,8 @@ void sysbeep()
|
|||
syscall(SC_beep);
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
int fsync([[maybe_unused]] int fd)
|
||||
{
|
||||
UNUSED_PARAM(fd);
|
||||
dbgprintf("FIXME: Implement fsync()\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue