Skip to content

Commit 901b7d5

Browse files
committed
Fix a bunch of compiler warnings. Not all, but a lot.
1 parent 15fb917 commit 901b7d5

File tree

10 files changed

+29
-191
lines changed

10 files changed

+29
-191
lines changed

AK/printf.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef unsigned int dword;
1313
static constexpr const char* h = "0123456789abcdef";
1414

1515
template<typename PutChFunc>
16-
[[gnu::always_inline]] int print_hex(PutChFunc putch, char*& bufptr, dword number, byte fields)
16+
[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, dword number, byte fields)
1717
{
1818
int ret = 0;
1919
byte shr_count = fields * 4;
@@ -26,7 +26,7 @@ template<typename PutChFunc>
2626
}
2727

2828
template<typename PutChFunc>
29-
[[gnu::always_inline]] int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
29+
[[gnu::always_inline]] inline int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
3030
{
3131
dword divisor = 1000000000;
3232
char ch;
@@ -67,7 +67,7 @@ template<typename PutChFunc>
6767
}
6868

6969
template<typename PutChFunc>
70-
[[gnu::always_inline]] int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
70+
[[gnu::always_inline]] inline int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
7171
{
7272
dword divisor = 134217728;
7373
char ch;
@@ -108,7 +108,7 @@ template<typename PutChFunc>
108108
}
109109

110110
template<typename PutChFunc>
111-
[[gnu::always_inline]] int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
111+
[[gnu::always_inline]] inline int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
112112
{
113113
size_t len = strlen(str);
114114
if (!fieldWidth || fieldWidth < len)
@@ -129,7 +129,7 @@ template<typename PutChFunc>
129129

130130

131131
template<typename PutChFunc>
132-
[[gnu::always_inline]] int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
132+
[[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
133133
{
134134
if (number < 0) {
135135
putch(bufptr, '-');
@@ -139,7 +139,7 @@ template<typename PutChFunc>
139139
}
140140

141141
template<typename PutChFunc>
142-
[[gnu::always_inline]] int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap)
142+
[[gnu::always_inline]] inline int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap)
143143
{
144144
const char *p;
145145

LibC/math.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ double round(double);
3434
float roundf(float);
3535
double fabs(double);
3636
float fabsf(float);
37-
double fmod(double);
38-
float fmodf(float);
37+
double fmod(double, double);
38+
float fmodf(float, float);
3939
double exp(double);
4040
float expf(float);
4141
double frexp(double, int* exp);
@@ -49,7 +49,7 @@ float sqrtf(float);
4949
double modf(double, double*);
5050
float modff(float, float*);
5151
double ldexp(double, int exp);
52-
double ldexpf(float, int exp);
52+
float ldexpf(float, int exp);
5353

5454
double pow(double x, double y);
5555

LibC/termcap.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ char* BC;
1515

1616
int tgetent(char* bp, const char* name)
1717
{
18+
(void)bp;
19+
(void)name;
1820
#ifdef TERMCAP_DEBUG
1921
fprintf(stderr, "tgetent: bp=%p, name='%s'\n", bp, name);
2022
#endif
@@ -67,7 +69,7 @@ void ensure_caps()
6769
caps->set("li", "25");
6870
}
6971

70-
char* tgetstr(char* id, char** area)
72+
char* tgetstr(const char* id, char** area)
7173
{
7274
ensure_caps();
7375
#ifdef TERMCAP_DEBUG
@@ -85,8 +87,9 @@ char* tgetstr(char* id, char** area)
8587
return nullptr;
8688
}
8789

88-
int tgetflag(char* id)
90+
int tgetflag(const char* id)
8991
{
92+
(void)id;
9093
#ifdef TERMCAP_DEBUG
9194
fprintf(stderr, "tgetflag: '%s'\n", id);
9295
#endif
@@ -96,7 +99,7 @@ int tgetflag(char* id)
9699
return 0;
97100
}
98101

99-
int tgetnum(char* id)
102+
int tgetnum(const char* id)
100103
{
101104
#ifdef TERMCAP_DEBUG
102105
fprintf(stderr, "tgetnum: '%s'\n", id);
@@ -109,11 +112,15 @@ int tgetnum(char* id)
109112

110113
char* tgoto(const char* cap, int col, int row)
111114
{
115+
(void)cap;
116+
(void)col;
117+
(void)row;
112118
assert(false);
113119
}
114120

115121
int tputs(const char* str, int affcnt, int (*putc)(int))
116122
{
123+
(void)affcnt;
117124
size_t len = strlen(str);
118125
for (size_t i = 0; i < len; ++i)
119126
putc(str[i]);

LibC/termcap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ extern char* UP;
99
extern char* BC;
1010

1111
int tgetent(char* bp, const char* name);
12-
int tgetflag(char* id);
13-
int tgetnum(char* id);
14-
char* tgetstr(char* id, char** area);
12+
int tgetflag(const char* id);
13+
int tgetnum(const char* id);
14+
char* tgetstr(const char* id, char** area);
1515
char* tgoto(const char* cap, int col, int row);
1616
int tputs(const char* str, int affcnt, int (*putc)(int));
1717

LibC/time.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ char *asctime(const struct tm*)
9494
assert(false);
9595
}
9696

97-
size_t strftime(char *s, size_t max, const char *format, const struct tm *tm)
97+
size_t strftime(char*, size_t, const char*, const struct tm*)
9898
{
9999
assert(false);
100100
}

LibC/unistd.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ extern "C" {
1616

1717
int chown(const char* pathname, uid_t owner, gid_t group)
1818
{
19+
(void)pathname;
20+
(void)owner;
21+
(void)group;
1922
assert(false);
2023
}
2124

LibGUI/GApplication.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ GApplication& GApplication::the()
1212

1313
GApplication::GApplication(int argc, char** argv)
1414
{
15+
(void)argc;
16+
(void)argv;
1517
ASSERT(!s_the);
1618
s_the = this;
1719
m_event_loop = make<GEventLoop>();

SharedGraphics/Painter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void Painter::set_pixel(const Point& p, Color color)
353353
m_target->scanline(point.y())[point.x()] = color.value();
354354
}
355355

356-
[[gnu::always_inline]] void Painter::set_pixel_with_draw_op(dword& pixel, const Color& color)
356+
[[gnu::always_inline]] inline void Painter::set_pixel_with_draw_op(dword& pixel, const Color& color)
357357
{
358358
if (m_draw_op == DrawOp::Copy)
359359
pixel = color.value();

Userland/guitest2.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <LibGUI/GApplication.h>
1919
#include <signal.h>
2020

21-
static GWindow* make_font_test_window();
2221
static GWindow* make_launcher_window();
2322

2423
void handle_sigchld(int)
@@ -35,47 +34,13 @@ int main(int argc, char** argv)
3534

3635
signal(SIGCHLD, handle_sigchld);
3736

38-
#if 0
39-
auto* font_test_window = make_font_test_window();
40-
font_test_window->show();
41-
#endif
42-
4337
auto* launcher_window = make_launcher_window();
4438
launcher_window->set_should_exit_app_on_close(true);
4539
launcher_window->show();
4640

4741
return app.exec();
4842
}
4943

50-
GWindow* make_font_test_window()
51-
{
52-
auto* window = new GWindow;
53-
window->set_title("Font test");
54-
window->set_rect({ 480, 100, 300, 80 });
55-
56-
auto* widget = new GWidget;
57-
window->set_main_widget(widget);
58-
widget->set_relative_rect({ 0, 0, 300, 80 });
59-
60-
auto* l1 = new GLabel(widget);
61-
l1->set_relative_rect({ 0, 0, 300, 20 });
62-
l1->set_text("0123456789");
63-
64-
auto* l2 = new GLabel(widget);
65-
l2->set_relative_rect({ 0, 20, 300, 20 });
66-
l2->set_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
67-
68-
auto* l3 = new GLabel(widget);
69-
l3->set_relative_rect({ 0, 40, 300, 20 });
70-
l3->set_text("abcdefghijklmnopqrstuvwxyz");
71-
72-
auto* l4 = new GLabel(widget);
73-
l4->set_relative_rect({ 0, 60, 300, 20 });
74-
l4->set_text("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
75-
76-
return window;
77-
}
78-
7944
GWindow* make_launcher_window()
8045
{
8146
auto* window = new GWindow;

Userland/sh.cpp

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -54,117 +54,6 @@ void handle_sigint(int)
5454
g->was_interrupted = true;
5555
}
5656

57-
static int sh_busy(int, char**)
58-
{
59-
struct sigaction sa;
60-
sa.sa_handler = did_receive_signal;
61-
sa.sa_flags = 0;
62-
sa.sa_mask = 0;
63-
sa.sa_restorer = nullptr;
64-
int rc = sigaction(SIGUSR1, &sa, nullptr);
65-
assert(rc == 0);
66-
printf("listening for signal SIGUSR1 while looping in userspace...\n");
67-
for (;;) {
68-
for (volatile int i = 0; i < 100000; ++i)
69-
;
70-
if (g_got_signal)
71-
break;
72-
}
73-
g_got_signal = false;
74-
return 0;
75-
}
76-
77-
static int sh_fork(int, char**)
78-
{
79-
pid_t pid = fork();
80-
printf("getpid()=%d, fork()=%d\n", getpid(), pid);
81-
return 0;
82-
}
83-
84-
static int sh_fe(int, char**)
85-
{
86-
pid_t pid = fork();
87-
if (!pid) {
88-
int rc = execvp("/bin/ps", nullptr);
89-
if (rc < 0) {
90-
perror("execvp");
91-
exit(1);
92-
}
93-
}
94-
return 0;
95-
}
96-
97-
static int sh_fef(int, char**)
98-
{
99-
pid_t pid = fork();
100-
if (!pid) {
101-
int rc = execvp("/bin/psx", nullptr);
102-
if (rc < 0) {
103-
perror("execvp");
104-
exit(1);
105-
}
106-
}
107-
return 0;
108-
}
109-
110-
static int sh_wt(int, char**)
111-
{
112-
const char* rodata_ptr = "foo";
113-
printf("Writing to rodata=%p...\n", rodata_ptr);
114-
*const_cast<char*>(rodata_ptr) = 0;
115-
116-
char* text_ptr = (char*)sh_fef;
117-
printf("Writing to text=%p...\n", text_ptr);
118-
*text_ptr = 0;
119-
return 0;
120-
}
121-
122-
static int sh_mf(int, char**)
123-
{
124-
int rc;
125-
int fd = open("/Banner.txt", O_RDONLY);
126-
if (fd < 0) {
127-
perror("open(/Banner.txt)");
128-
return 1;
129-
}
130-
printf("opened /Banner.txt, calling mmap...\n");
131-
byte* data = (byte*)mmap(nullptr, getpagesize(), PROT_READ, MAP_PRIVATE, fd, 0);
132-
if (data == MAP_FAILED) {
133-
perror("mmap()");
134-
goto close_it;
135-
}
136-
printf("mapped file @ %p\n", data);
137-
printf("contents: %b %b %b %b\n", data[0], data[1], data[2], data[3]);
138-
139-
rc = munmap(data, getpagesize());
140-
printf("munmap() returned %d\n", rc);
141-
142-
close_it:
143-
rc = close(fd);
144-
printf("close() returned %d\n", rc);
145-
return 0;
146-
}
147-
148-
static int sh_mp(int, char**)
149-
{
150-
int fd = open("/kernel.map", O_RDONLY);
151-
if (fd < 0) {
152-
perror("open(/kernel.map)");
153-
return 1;
154-
}
155-
printf("opened /kernel.map, calling mmap...\n");
156-
byte* data = (byte*)mmap(nullptr, getpagesize() * 10, PROT_READ, MAP_PRIVATE, fd, 0);
157-
if (data == MAP_FAILED) {
158-
perror("mmap()");
159-
return 1;
160-
}
161-
printf("mapped file @ %p\n", data);
162-
printf("contents: %c%c%c%c%c%c%c%c...\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
163-
164-
printf("leaving it open :)\n");
165-
return 0;
166-
}
167-
16857
static int sh_exit(int, char**)
16958
{
17059
printf("Good-bye!\n");
@@ -227,34 +116,6 @@ static bool handle_builtin(int argc, char** argv, int& retval)
227116
retval = sh_exit(argc, argv);
228117
return true;
229118
}
230-
if (!strcmp(argv[0], "fe")) {
231-
retval = sh_fe(argc, argv);
232-
return true;
233-
}
234-
if (!strcmp(argv[0], "fef")) {
235-
retval = sh_fef(argc, argv);
236-
return true;
237-
}
238-
if (!strcmp(argv[0], "busy")) {
239-
retval = sh_busy(argc, argv);
240-
return true;
241-
}
242-
if (!strcmp(argv[0], "wt")) {
243-
retval = sh_wt(argc, argv);
244-
return true;
245-
}
246-
if (!strcmp(argv[0], "mf")) {
247-
retval = sh_mf(argc, argv);
248-
return true;
249-
}
250-
if (!strcmp(argv[0], "mp")) {
251-
retval = sh_mp(argc, argv);
252-
return true;
253-
}
254-
if (!strcmp(argv[0], "fork")) {
255-
retval = sh_fork(argc, argv);
256-
return true;
257-
}
258119
return false;
259120
}
260121

0 commit comments

Comments
 (0)