mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Fix warnings found by clang r180088.
This commit is contained in:
parent
f29b75fb1d
commit
efe37364eb
38
darkhttpd.c
38
darkhttpd.c
@ -76,10 +76,6 @@ static const int debug = 1;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ( ((a)<(b)) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
#if defined(O_EXCL) && !defined(O_EXLOCK)
|
||||
# define O_EXLOCK O_EXCL
|
||||
#endif
|
||||
@ -172,20 +168,11 @@ struct { \
|
||||
|
||||
#define LIST_FIRST(head) ((head)->lh_first)
|
||||
|
||||
#define LIST_FOREACH(var, head, field) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
|
||||
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
|
||||
@ -203,7 +190,7 @@ struct { \
|
||||
} while (0)
|
||||
/* [<-] */
|
||||
|
||||
LIST_HEAD(conn_list_head, connection) connlist =
|
||||
static LIST_HEAD(conn_list_head, connection) connlist =
|
||||
LIST_HEAD_INITIALIZER(conn_list_head);
|
||||
|
||||
struct connection {
|
||||
@ -244,9 +231,9 @@ struct mime_mapping {
|
||||
char *extension, *mimetype;
|
||||
};
|
||||
|
||||
struct mime_mapping *mime_map = NULL;
|
||||
size_t mime_map_size = 0;
|
||||
size_t longest_ext = 0;
|
||||
static struct mime_mapping *mime_map = NULL;
|
||||
static size_t mime_map_size = 0;
|
||||
static size_t longest_ext = 0;
|
||||
|
||||
/* If a connection is idle for idletime seconds or more, it gets closed and
|
||||
* removed from the connlist. Set to 0 to remove the timeout
|
||||
@ -569,7 +556,7 @@ static char *make_safe_url(char *url) {
|
||||
* unsorted order. Makes copies of extension and mimetype strings.
|
||||
*/
|
||||
static void add_mime_mapping(const char *extension, const char *mimetype) {
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
assert(strlen(extension) > 0);
|
||||
assert(strlen(mimetype) > 0);
|
||||
|
||||
@ -1687,7 +1674,7 @@ static void generate_dir_listing(struct connection *conn, const char *path) {
|
||||
append(listing, "\n</body>\n</html>\n");
|
||||
|
||||
conn->reply = listing->str;
|
||||
conn->reply_length = listing->length;
|
||||
conn->reply_length = (off_t)listing->length;
|
||||
free(listing); /* don't free inside of listing */
|
||||
|
||||
conn->header_length = xasprintf(&(conn->header),
|
||||
@ -2067,7 +2054,10 @@ static ssize_t send_from_file(const int s, const int fd,
|
||||
size = 1<<20;
|
||||
return sendfile(s, fd, &ofs, size);
|
||||
#else
|
||||
|
||||
/* Fake sendfile() with read(). */
|
||||
# ifndef min
|
||||
# define min(a,b) ( ((a)<(b)) ? (a) : (b) )
|
||||
# endif
|
||||
char buf[1<<15];
|
||||
size_t amount = min(sizeof(buf), size);
|
||||
ssize_t numread;
|
||||
@ -2191,8 +2181,6 @@ static void httpd_poll(void) {
|
||||
MAX_FD_SET(conn->socket, &send_set);
|
||||
bother_with_timeout = 1;
|
||||
break;
|
||||
|
||||
default: errx(1, "invalid state");
|
||||
}
|
||||
}
|
||||
#undef MAX_FD_SET
|
||||
@ -2237,8 +2225,6 @@ static void httpd_poll(void) {
|
||||
case DONE:
|
||||
/* (handled later; ignore for now as it's a valid state) */
|
||||
break;
|
||||
|
||||
default: errx(1, "invalid state");
|
||||
}
|
||||
|
||||
if (conn->state == DONE) {
|
||||
@ -2320,7 +2306,7 @@ static void daemonize_finish(void) {
|
||||
close(fd_null);
|
||||
}
|
||||
|
||||
/* [<-] pidfile helpers, based on FreeBSD src/lib/libutil/pidfile.c,v 1.3
|
||||
/* [->] pidfile helpers, based on FreeBSD src/lib/libutil/pidfile.c,v 1.3
|
||||
* Original was copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
*/
|
||||
static int pidfile_fd = -1;
|
||||
@ -2343,7 +2329,7 @@ static int pidfile_read(void) {
|
||||
if (fd == -1)
|
||||
err(1, " after create failed");
|
||||
|
||||
i = read(fd, buf, sizeof(buf) - 1);
|
||||
i = (int)read(fd, buf, sizeof(buf) - 1);
|
||||
if (i == -1)
|
||||
err(1, "read from pidfile failed");
|
||||
xclose(fd);
|
||||
|
@ -7,7 +7,7 @@ TARGET=$(dirname $0)/../darkhttpd.c
|
||||
# Adjust to suit:
|
||||
LLVM=$HOME/llvm
|
||||
|
||||
$LLVM/install/bin/clang \
|
||||
-Weverything -Wno-unreachable-code -Wno-padded \
|
||||
-O $TARGET
|
||||
$LLVM/install/bin/clang -Weverything -O \
|
||||
-Wno-unreachable-code -Wno-padded -Wno-disabled-macro-expansion \
|
||||
$TARGET
|
||||
rm -f a.out
|
||||
|
Loading…
Reference in New Issue
Block a user