Enable -Wall
This commit is contained in:
@ -84,7 +84,7 @@ static void http_process(http_worker_t *worker, FILE *stream)
|
||||
continue;
|
||||
|
||||
// allow last character to match `?` or ` `
|
||||
if (worker->client_method[nlen-1] == name[nlen-1] || name[nlen-1] == '?' && worker->client_method[nlen-1] == ' ') {
|
||||
if (worker->client_method[nlen-1] == name[nlen-1] || (name[nlen-1] == '?' && worker->client_method[nlen-1] == ' ')) {
|
||||
worker->current_method = &worker->methods[i];
|
||||
break;
|
||||
}
|
||||
@ -130,7 +130,7 @@ static void http_client(http_worker_t *worker)
|
||||
static int http_worker(http_worker_t *worker)
|
||||
{
|
||||
while (1) {
|
||||
int addrlen = sizeof(worker->client_addr);
|
||||
unsigned addrlen = sizeof(worker->client_addr);
|
||||
worker->client_fd = accept(worker->listen_fd, (struct sockaddr *)&worker->client_addr, &addrlen);
|
||||
if (worker->client_fd < 0) {
|
||||
goto error;
|
||||
@ -152,7 +152,7 @@ int http_server(http_server_options_t *options, http_method_t *methods)
|
||||
return -1;
|
||||
}
|
||||
|
||||
sigaction(SIGPIPE, &(struct sigaction){ SIG_IGN }, NULL);
|
||||
sigaction(SIGPIPE, &(struct sigaction){{ SIG_IGN }}, NULL);
|
||||
|
||||
for (int worker = 0; worker < options->maxcons; worker++) {
|
||||
char name[20];
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
typedef struct buffer_s buffer_t;
|
||||
@ -17,7 +18,7 @@ typedef struct http_method_s {
|
||||
const char *name;
|
||||
http_method_fn func;
|
||||
const char *content_type;
|
||||
const char *content_body;
|
||||
const void *content_body;
|
||||
unsigned content_length;
|
||||
unsigned *content_lengthp;
|
||||
} http_method_t;
|
||||
@ -38,8 +39,8 @@ typedef struct http_worker_s {
|
||||
} http_worker_t;
|
||||
|
||||
typedef struct http_server_options_s {
|
||||
int port;
|
||||
int maxcons;
|
||||
unsigned port;
|
||||
unsigned maxcons;
|
||||
} http_server_options_t;
|
||||
|
||||
int http_server(http_server_options_t *options, http_method_t *methods);
|
||||
|
@ -64,7 +64,7 @@ static int http_ffmpeg_write_to_stream(void *opaque, uint8_t *buf, int buf_size)
|
||||
size_t n = fwrite(buf, 1, buf_size, status->stream);
|
||||
fflush(status->stream);
|
||||
|
||||
LOG_DEBUG(status, "http_ffmpeg_write_to_stream: offset=%d, n=%d, buf_size=%d, error=%d",
|
||||
LOG_DEBUG(status, "http_ffmpeg_write_to_stream: offset=%d, n=%zu, buf_size=%d, error=%d",
|
||||
status->stream_offset, n, buf_size, ferror(status->stream));
|
||||
status->stream_offset += n;
|
||||
if (ferror(status->stream))
|
||||
|
@ -65,8 +65,6 @@ bool h264_is_key_frame(buffer_t *buf)
|
||||
|
||||
int http_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_video_status_t *status)
|
||||
{
|
||||
unsigned char *data = buf->start;
|
||||
|
||||
if (!status->had_key_frame) {
|
||||
status->had_key_frame = h264_is_key_frame(buf);
|
||||
}
|
||||
|
@ -18,14 +18,6 @@ static const char *const STREAM_HEADER = "HTTP/1.0 200 OK\r\n"
|
||||
"Content-Type: multipart/x-mixed-replace;boundary=" PART_BOUNDARY "\r\n"
|
||||
"\r\n"
|
||||
"--" PART_BOUNDARY "\r\n";
|
||||
static const char *const STREAM_ERROR = "Content-Type: text/plain\r\n"
|
||||
"\r\n"
|
||||
"Error: %d (%s).\r\n"
|
||||
"--" PART_BOUNDARY "\r\n";
|
||||
static const char *const STREAM_TIMEDOUT = "Content-Type: text/plain\r\n"
|
||||
"\r\n"
|
||||
"Timedout.\r\n"
|
||||
"--" PART_BOUNDARY "\r\n";
|
||||
static const char *const STREAM_PART = "Content-Type: " CONTENT_TYPE "\r\n" CONTENT_LENGTH ": %u\r\n\r\n";
|
||||
static const char *const STREAM_BOUNDARY = "\r\n"
|
||||
"--" PART_BOUNDARY "\r\n";
|
||||
@ -57,7 +49,7 @@ int http_snapshot_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, FI
|
||||
{
|
||||
fprintf(stream, "HTTP/1.1 200 OK\r\n");
|
||||
fprintf(stream, "Content-Type: image/jpeg\r\n");
|
||||
fprintf(stream, "Content-Length: %d\r\n", buf->used);
|
||||
fprintf(stream, "Content-Length: %zu\r\n", buf->used);
|
||||
fprintf(stream, "\r\n");
|
||||
fwrite(buf->start, buf->used, 1, stream);
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user