Skip to content

Commit e6f6c7d

Browse files
committed
Remove compiler warnings.
Mongrel2 now compiles warning free on clang, and mostly warning free on GCC with only a few bstring related issues.
1 parent c830e34 commit e6f6c7d

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

src/adt/dict.c

+2
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,13 @@ int dict_contains(dict_t *dict, dnode_t *node)
948948

949949
static dnode_t *dnode_alloc(void *context)
950950
{
951+
(void)(context); // unused
951952
return malloc(sizeof *dnode_alloc(NULL));
952953
}
953954

954955
static void dnode_free(dnode_t *node, void *context)
955956
{
957+
(void)(context); // unused
956958
free(node);
957959
}
958960

src/adt/hash.c

+2
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,13 @@ int hash_isempty(hash_t *hash)
747747

748748
static hnode_t *hnode_alloc(void *context)
749749
{
750+
(void)(context); // unused
750751
return malloc(sizeof *hnode_alloc(NULL));
751752
}
752753

753754
static void hnode_free(hnode_t *node, void *context)
754755
{
756+
(void)(context); // unused
755757
free(node);
756758
}
757759

src/bstr/bsafe.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ char * strcpy (char *dst, const char *src);
2424
char * strcat (char *dst, const char *src);
2525

2626
char * strcpy (char *dst, const char *src) {
27-
dst = dst;
28-
src = src;
27+
(void)(dst);
28+
(void)(src);
2929
fprintf (stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
3030
if (bsafeShouldExit) exit (-1);
3131
return NULL;
3232
}
3333

3434
char * strcat (char *dst, const char *src) {
35-
dst = dst;
36-
src = src;
35+
(void)(dst);
36+
(void)(src);
3737
fprintf (stderr, "bsafe error: strcat() is not safe, use bconcat instead.\n");
3838
if (bsafeShouldExit) exit (-1);
3939
return NULL;
4040
}
4141

4242
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
4343
char * (gets) (char * buf) {
44-
buf = buf;
44+
(void)(buf);
4545
fprintf (stderr, "bsafe error: gets() is not safe, use bgets.\n");
4646
if (bsafeShouldExit) exit (-1);
4747
return NULL;
@@ -58,17 +58,17 @@ char * (gets) (char * buf) {
5858
// }
5959

6060
char * (strncat) (char *dst, const char *src, size_t n) {
61-
dst = dst;
62-
src = src;
63-
n = n;
61+
(void)(dst);
62+
(void)(src);
63+
(void)(n);
6464
fprintf (stderr, "bsafe error: strncat() is not safe, use bconcat then btrunc\n\tor cstr2tbstr, btrunc then bconcat instead.\n");
6565
if (bsafeShouldExit) exit (-1);
6666
return NULL;
6767
}
6868

6969
char * (strtok) (char *s1, const char *s2) {
70-
s1 = s1;
71-
s2 = s2;
70+
(void)(s1);
71+
(void)(s2);
7272
fprintf (stderr, "bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
7373
if (bsafeShouldExit) exit (-1);
7474
return NULL;

src/bstr/bstraux.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ int i, l, c;
198198
}
199199

200200
static size_t readNothing (void *buff, size_t elsize, size_t nelem, void *parm) {
201-
buff = buff;
202-
elsize = elsize;
203-
nelem = nelem;
204-
parm = parm;
201+
(void)(buff);
202+
(void)(elsize);
203+
(void)(nelem);
204+
(void)(parm);
205205
return 0; /* Immediately indicate EOF. */
206206
}
207207

src/dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void FileRecord_destroy(FileRecord *file)
263263

264264
static inline char *url_decode(const char *in, char *out)
265265
{
266-
char *cur; /* will seek % in input */
266+
const char *cur; /* will seek % in input */
267267
char d1; /* will contain candidate for 1st digit */
268268
char d2; /* will contain candidate for 2nd digit */
269269
char *res = out; /* just for convienience */

src/io.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static ssize_t plain_stream_file(IOBuf *iob, int fd, off_t len)
126126
return -1;
127127
}
128128

129-
static int ssl_fdsend_wrapper(void *p_iob, unsigned char *ubuffer, size_t len)
129+
static int ssl_fdsend_wrapper(void *p_iob, const unsigned char *ubuffer, size_t len)
130130
{
131131
IOBuf *iob = (IOBuf *) p_iob;
132132
return fdsend(iob->fd, (char *) ubuffer, len);
@@ -630,14 +630,13 @@ int IOBuf_stream(IOBuf *from, IOBuf *to, int total)
630630
int remain = total;
631631
int avail = 0;
632632
int rc = 0;
633-
char *data = NULL;
634633

635634
if(from->len > to->len) IOBuf_resize(to, from->len);
636635

637636
while(remain > 0) {
638637
need = remain <= from->len ? remain : from->len;
639638

640-
data = IOBuf_read(from, need, &avail);
639+
IOBuf_read(from, need, &avail);
641640
check_debug(avail > 0, "Nothing in read buffer.");
642641

643642
rc = IOBuf_send_all(to, IOBuf_start(from), avail);

tests/bstr_tests.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ static int test23_aux_open (struct sbstr * sb, bstring b) {
20552055
static int test23_aux_splitcb (void * parm, int ofs, const struct tagbstring * entry) {
20562056
bstring b = (bstring) parm;
20572057

2058-
ofs = ofs;
2058+
(void)(ofs);
20592059
if (b->slen > 0) bconchar (b, (char) '|');
20602060
bconcat (b, entry);
20612061
return 0;
@@ -2070,7 +2070,7 @@ struct tagBss {
20702070
static int test23_aux_splitcbx (void * parm, int ofs, const struct tagbstring * entry) {
20712071
struct tagBss * p = (struct tagBss *) parm;
20722072

2073-
ofs = ofs;
2073+
(void)(ofs);
20742074
if (!p->first) {
20752075
bconchar (p->b, (char) p->sc);
20762076
} else p->first = 0;
@@ -3735,8 +3735,8 @@ int taskmain (int argc, char * argv[])
37353735

37363736
int ret = 0;
37373737

3738-
argc = argc;
3739-
argv = argv;
3738+
(void)(argc);
3739+
(void)(argv);
37403740

37413741
debug ("Direct case testing of bstring core functions");
37423742

tests/superpoll_tests.c

-2
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ int nr_pending_tokens;
7575

7676
void really_send_toke(struct token *toke)
7777
{
78-
struct fdinfo *inf;
7978
int *fds;
8079
int fd;
8180
int pipe_idx = nr_pipes - toke->thread - 1;
8281

8382
fds = pipefds[pipe_idx].fds;
8483
fd = fds[WRITE];
85-
inf = &fdinfo[fd];
8684

8785
debug("sending on pipe index %u, fd %d", pipe_idx, fd);
8886

tools/m2sh/src/commands/running.c

+5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@
3333
*/
3434

3535
#include <signal.h>
36+
3637
#include <zmq.h>
38+
3739
#include <tnetstrings.h>
3840
#include <tnetstrings_impl.h>
3941
#include <config/db.h>
4042
#include <handler.h>
43+
#include <pattern.h>
44+
#include <register.h>
45+
4146
#include "../linenoise.h"
4247
#include "../commands.h"
4348
#include "../query_print.h"

0 commit comments

Comments
 (0)