Enable -Wall
This commit is contained in:
parent
eaf4e06989
commit
9c7f5fed12
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -68,6 +68,8 @@
|
||||
"fourcc.h": "c",
|
||||
"device.h": "c",
|
||||
"log.h": "c",
|
||||
"buffer_list.h": "c"
|
||||
"buffer_list.h": "c",
|
||||
"buffer.h": "c",
|
||||
"stdbool.h": "c"
|
||||
}
|
||||
}
|
||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ SRC := $(wildcard **/*.c **/*/*.c **/*.cc **/*/*.cc)
|
||||
HEADERS := $(wildcard **/*.h **/*/*.h **/*.hh **/*/*.hh)
|
||||
HTML := $(wildcard html/*.js html/*.html)
|
||||
|
||||
CFLAGS := -Werror -g -I$(PWD)
|
||||
CFLAGS := -Werror -Wall -g -I$(PWD)
|
||||
LDLIBS := -lpthread -lstdc++
|
||||
|
||||
ifneq (x,x$(shell which ccache))
|
||||
|
@ -119,7 +119,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int http_fd = -1;
|
||||
int ret = -1;
|
||||
const char *env;
|
||||
|
||||
if (parse_opts(all_options, argc, argv) < 0) {
|
||||
return -1;
|
||||
|
@ -128,7 +128,6 @@ int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn
|
||||
}
|
||||
}
|
||||
|
||||
ok:
|
||||
buffer_lock_use(buf_lock, -1);
|
||||
return frames;
|
||||
|
||||
|
@ -127,7 +127,7 @@ int buffer_list_enqueue(buffer_list_t *buf_list, buffer_t *dma_buf)
|
||||
memcpy(buf->start, dma_buf->start, dma_buf->used);
|
||||
uint64_t after = get_monotonic_time_us(NULL, NULL);
|
||||
|
||||
LOG_DEBUG(buf, "mmap copy: dest=%p, src=%p (%s), size=%zu, space=%zu, time=%dllus",
|
||||
LOG_DEBUG(buf, "mmap copy: dest=%p, src=%p (%s), size=%zu, space=%zu, time=%luus",
|
||||
buf->start, dma_buf->start, dma_buf->name, dma_buf->used, buf->length, after-before);
|
||||
} else {
|
||||
LOG_DEBUG(buf, "dmabuf copy: dest=%p, src=%p (%s, dma_fd=%d), size=%zu",
|
||||
@ -141,8 +141,6 @@ int buffer_list_enqueue(buffer_list_t *buf_list, buffer_t *dma_buf)
|
||||
buf->used = dma_buf->used;
|
||||
buffer_consumed(buf, "copy-data");
|
||||
return 1;
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_t *buffer_list_dequeue(buffer_list_t *buf_list)
|
||||
@ -162,7 +160,7 @@ buffer_t *buffer_list_dequeue(buffer_list_t *buf_list)
|
||||
buf->enqueued = false;
|
||||
buf->mmap_reflinks = 1;
|
||||
|
||||
LOG_DEBUG(buf_list, "Grabbed mmap buffer=%u, bytes=%d, used=%d, frame=%d, linked=%s",
|
||||
LOG_DEBUG(buf_list, "Grabbed mmap buffer=%u, bytes=%zu, used=%zu, frame=%d, linked=%s",
|
||||
buf->index,
|
||||
buf->length,
|
||||
buf->used,
|
||||
|
@ -22,7 +22,7 @@ typedef struct camera_options_s {
|
||||
bool allow_dma;
|
||||
float high_res_factor;
|
||||
float low_res_factor;
|
||||
int auto_reconnect;
|
||||
unsigned auto_reconnect;
|
||||
|
||||
char options[CAMERA_OPTIONS_LENGTH];
|
||||
|
||||
|
@ -54,7 +54,6 @@ buffer_list_t *device_open_buffer_list(device_t *dev, bool do_capture, unsigned
|
||||
|
||||
buffer_list_t *device_open_buffer_list2(device_t *dev, const char *path, bool do_capture, unsigned width, unsigned height, unsigned format, unsigned bytesperline, int nbufs, bool do_mmap)
|
||||
{
|
||||
unsigned type;
|
||||
char name[64];
|
||||
int index = 0;
|
||||
buffer_list_t *buf_list;
|
||||
@ -239,7 +238,7 @@ void device_set_option_list(device_t *dev, const char *option_list)
|
||||
char *string = start;
|
||||
char *option;
|
||||
|
||||
while (option = strsep(&string, OPTION_VALUE_LIST_SEP)) {
|
||||
while ((option = strsep(&string, OPTION_VALUE_LIST_SEP)) != NULL) {
|
||||
char *value = option;
|
||||
char *key = strsep(&value, "=");
|
||||
|
||||
|
@ -37,7 +37,7 @@ int libcamera_buffer_open(buffer_t *buf)
|
||||
}
|
||||
|
||||
if (offset + length != plane.offset) {
|
||||
LOG_ERROR(buf, "Plane is not continuous: offset=%lld, expected=%lld", plane.offset, offset + length);
|
||||
LOG_ERROR(buf, "Plane is not continuous: offset=%u, expected=%lu", plane.offset, offset + length);
|
||||
}
|
||||
|
||||
length += plane.length;
|
||||
@ -51,7 +51,7 @@ int libcamera_buffer_open(buffer_t *buf)
|
||||
buf->dma_fd = dma_fd.get();
|
||||
buf->length = length;
|
||||
|
||||
LOG_DEBUG(buf, "Mapped buffer: start=%p, length=%d, fd=%d, planes=%d",
|
||||
LOG_DEBUG(buf, "Mapped buffer: start=%p, length=%zu, fd=%d, planes=%lu",
|
||||
buf->start, buf->length, buf->dma_fd, buffer->planes().size());
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ int libcamera_buffer_enqueue(buffer_t *buf, const char *who)
|
||||
|
||||
request->reuse(libcamera::Request::ReuseBuffers);
|
||||
|
||||
if (buf->buf_list->dev->libcamera->camera->queueRequest(buf->libcamera->request.get()) < 0) {
|
||||
if (camera->queueRequest(buf->libcamera->request.get()) < 0) {
|
||||
LOG_ERROR(buf, "Can't queue buffer.");
|
||||
}
|
||||
return 0;
|
||||
@ -107,7 +107,7 @@ int libcamera_buffer_list_dequeue(buffer_list_t *buf_list, buffer_t **bufp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (index >= buf_list->nbufs) {
|
||||
if (index >= (unsigned)buf_list->nbufs) {
|
||||
LOG_INFO(buf_list, "Received invalid index from `read`: %d >= %d", index, buf_list->nbufs);
|
||||
return -1;
|
||||
}
|
||||
|
@ -86,6 +86,9 @@ int libcamera_device_set_option(device_t *dev, const char *keyp, const char *val
|
||||
libcamera::ControlValue control_value;
|
||||
|
||||
switch (control_id->type()) {
|
||||
case libcamera::ControlTypeNone:
|
||||
break;
|
||||
|
||||
case libcamera::ControlTypeBool:
|
||||
control_value.set<bool>(atoi(value));
|
||||
break;
|
||||
|
@ -11,7 +11,6 @@
|
||||
int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_list_t **buf_lists, int max_n, int *max_timeout_ms)
|
||||
{
|
||||
int n = 0, nlinks = 0;
|
||||
uint64_t now_us = get_monotonic_time_us(NULL, NULL);
|
||||
|
||||
for (nlinks = 0; all_links[nlinks].source; nlinks++);
|
||||
|
||||
@ -143,7 +142,6 @@ int links_step(link_t *all_links, int timeout_now_ms, int *timeout_next_ms)
|
||||
struct pollfd fds[N_FDS] = {0};
|
||||
link_t *links[N_FDS];
|
||||
buffer_list_t *buf_lists[N_FDS];
|
||||
buffer_t *buf;
|
||||
|
||||
int n = _build_fds(all_links, fds, links, buf_lists, N_FDS, &timeout_now_ms);
|
||||
print_pollfds(fds, n);
|
||||
@ -220,7 +218,7 @@ int links_step(link_t *all_links, int timeout_now_ms, int *timeout_next_ms)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if (buf = buffer_list_find_slot(buf_list)) {
|
||||
if ((buf = buffer_list_find_slot(buf_list)) != NULL) {
|
||||
buffer_consumed(buf, "enqueued");
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ int v4l2_buffer_open(buffer_t *buf)
|
||||
struct v4l2_plane v4l2_plane = {0};
|
||||
|
||||
buffer_list_t *buf_list = buf->buf_list;
|
||||
device_t *dev = buf_list->dev;
|
||||
|
||||
buf->v4l2 = calloc(1, sizeof(buffer_v4l2_t));
|
||||
|
||||
@ -29,7 +28,7 @@ int v4l2_buffer_open(buffer_t *buf)
|
||||
v4l2_buf.memory = V4L2_MEMORY_DMABUF;
|
||||
}
|
||||
|
||||
ERR_IOCTL(buf_list, buf_list->v4l2->dev_fd, VIDIOC_QUERYBUF, &v4l2_buf, "Cannot query buffer %d", index);
|
||||
ERR_IOCTL(buf_list, buf_list->v4l2->dev_fd, VIDIOC_QUERYBUF, &v4l2_buf, "Cannot query buffer %d", buf->index);
|
||||
|
||||
uint64_t mem_offset = 0;
|
||||
|
||||
@ -51,7 +50,7 @@ int v4l2_buffer_open(buffer_t *buf)
|
||||
v4l2_exp.type = v4l2_buf.type;
|
||||
v4l2_exp.index = buf->index;
|
||||
v4l2_exp.plane = 0;
|
||||
ERR_IOCTL(buf_list, buf_list->v4l2->dev_fd, VIDIOC_EXPBUF, &v4l2_exp, "Can't export queue buffer=%u to DMA", index);
|
||||
ERR_IOCTL(buf_list, buf_list->v4l2->dev_fd, VIDIOC_EXPBUF, &v4l2_exp, "Can't export queue buffer=%u to DMA", buf->index);
|
||||
buf->dma_fd = v4l2_exp.fd;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ int v4l2_buffer_list_open(buffer_list_t *buf_list)
|
||||
|
||||
// JPEG is in 16x16 blocks (shrink image to fit) (but adapt to 32x32)
|
||||
// And ISP output
|
||||
if (strstr(buf_list->name, "JPEG") || strstr(buf_list->name, "H264") || buf_list->do_capture && strstr(buf_list->name, "ISP")) {
|
||||
if (strstr(buf_list->name, "JPEG") || strstr(buf_list->name, "H264") || (buf_list->do_capture && strstr(buf_list->name, "ISP"))) {
|
||||
buffer_format_t org_fmt = buf_list->fmt;
|
||||
fmt.width = shrink_to_block(fmt.width, 32);
|
||||
fmt.height = shrink_to_block(fmt.height, 32);
|
||||
|
@ -24,7 +24,7 @@ int v4l2_device_open(device_t *dev)
|
||||
LOG_ERROR(dev, "Device doesn't support streaming IO");
|
||||
}
|
||||
|
||||
strcpy(dev->bus_info, v4l2_cap.bus_info);
|
||||
strcpy(dev->bus_info, (char *)v4l2_cap.bus_info);
|
||||
dev->v4l2->subdev_fd = v4l2_device_open_v4l2_subdev(dev, 0);
|
||||
|
||||
v4l2_device_query_controls(dev, dev->v4l2->dev_fd);
|
||||
|
@ -22,7 +22,7 @@ int v4l2_device_open_media_device(device_t *dev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char path[256];
|
||||
char path[300];
|
||||
sprintf(path, "/sys/dev/char/%d:%d/device", major(st.st_rdev), minor(st.st_rdev));
|
||||
|
||||
struct dirent **namelist;
|
||||
@ -47,7 +47,6 @@ int v4l2_device_open_media_device(device_t *dev)
|
||||
}
|
||||
free(namelist);
|
||||
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -94,7 +93,7 @@ int v4l2_device_open_v4l2_subdev(device_t *dev, int subdev)
|
||||
}
|
||||
|
||||
if (strstr(last, "/v4l-subdev") != last) {
|
||||
LOG_VERBOSE(dev, "Link '%s' does not contain '/v4l-subdev'", link, path);
|
||||
LOG_VERBOSE(dev, "Link '%s' does not contain '/v4l-subdev'", link);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ error:
|
||||
static int v4l2_device_query_control_iter_id(device_t *dev, int fd, uint32_t *id)
|
||||
{
|
||||
struct v4l2_query_ext_ctrl qctrl = { .id = *id };
|
||||
void *data = NULL;
|
||||
|
||||
if (0 != ioctl (fd, VIDIOC_QUERY_EXT_CTRL, &qctrl)) {
|
||||
return -1;
|
||||
@ -120,7 +119,7 @@ int v4l2_device_set_option(device_t *dev, const char *key, const char *value)
|
||||
char *token;
|
||||
int tokens = 0;
|
||||
|
||||
for ( ; token = strsep(&string, ","); tokens++) {
|
||||
for ( ; (token = strsep(&string, ",")) != NULL; tokens++) {
|
||||
if (tokens >= control->control.elems)
|
||||
continue;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/v4l2-subdev.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -140,10 +140,10 @@ int ffmpeg_remuxer_feed(ffmpeg_remuxer_t *remuxer, int nframes)
|
||||
ret = av_read_frame(remuxer->input_context, remuxer->packet);
|
||||
if (ret == AVERROR_EOF) {
|
||||
ret = 0;
|
||||
LOG_DEBUG(remuxer, "av_read_frame: EOF", ret);
|
||||
LOG_DEBUG(remuxer, "av_read_frame: EOF");
|
||||
break;
|
||||
} else if (ret < 0) {
|
||||
LOG_DEBUG(remuxer, "av_read_frame: %08x, pts: %d", ret, remuxer->packet->pts);
|
||||
LOG_DEBUG(remuxer, "av_read_frame: %08x, pts: %ld", ret, remuxer->packet->pts);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -155,7 +155,6 @@ int ffmpeg_remuxer_feed(ffmpeg_remuxer_t *remuxer, int nframes)
|
||||
remuxer->frames++;
|
||||
frames++;
|
||||
|
||||
AVStream *in_stream = remuxer->input_context->streams[remuxer->packet->stream_index];
|
||||
remuxer->packet->stream_index = 0;
|
||||
AVStream *out_stream = remuxer->output_context->streams[remuxer->packet->stream_index];
|
||||
|
||||
@ -173,7 +172,7 @@ int ffmpeg_remuxer_feed(ffmpeg_remuxer_t *remuxer, int nframes)
|
||||
av_packet_unref(remuxer->packet);
|
||||
|
||||
if (ret == AVERROR_EOF) {
|
||||
LOG_DEBUG(remuxer, "av_interleaved_write_frame: EOF, pts: %d, since_start: %d", ret, pts, since_start);
|
||||
LOG_DEBUG(remuxer, "av_interleaved_write_frame: EOF, pts: %d, since_start: %d", pts, since_start);
|
||||
} else {
|
||||
LOG_DEBUG(remuxer, "av_interleaved_write_frame: %08x, pts: %d, since_start: %d", ret, pts, since_start);
|
||||
}
|
||||
@ -190,7 +189,7 @@ int ffmpeg_remuxer_flush(ffmpeg_remuxer_t *remuxer)
|
||||
{
|
||||
int ret = av_write_frame(remuxer->output_context, NULL);
|
||||
if (ret == AVERROR_EOF) {
|
||||
LOG_DEBUG(remuxer, "av_write_frame (flush): EOF", ret);
|
||||
LOG_DEBUG(remuxer, "av_write_frame (flush): EOF");
|
||||
} else {
|
||||
LOG_DEBUG(remuxer, "av_write_frame (flush): %08x", ret);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
typedef struct {
|
||||
|
@ -5,9 +5,6 @@
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
static int option_handler_print(option_t *option, char *data);
|
||||
static int option_handler_set(option_t *option, char *data);
|
||||
|
||||
static void print_help(option_t *options)
|
||||
{
|
||||
for (int i = 0; options[i].name; i++) {
|
||||
@ -20,7 +17,7 @@ static void print_help(option_t *options)
|
||||
char *token;
|
||||
int tokens = 0;
|
||||
|
||||
while (token = strsep(&string, OPTION_VALUE_LIST_SEP)) {
|
||||
while ((token = strsep(&string, OPTION_VALUE_LIST_SEP)) != NULL) {
|
||||
if (tokens++ > 0)
|
||||
printf("\n%40s\t", "");
|
||||
printf("%s", token);
|
||||
|
@ -27,12 +27,12 @@ typedef struct options_s {
|
||||
|
||||
#define OPTION_VALUE_LIST_SEP ";"
|
||||
|
||||
#define OPTION_FORMAT_uint "%d"
|
||||
#define OPTION_FORMAT_uint "%u"
|
||||
#define OPTION_FORMAT_hex "%08x"
|
||||
#define OPTION_FORMAT_bool "%d"
|
||||
#define OPTION_FORMAT_float "%f"
|
||||
#define OPTION_FORMAT_string "%s"
|
||||
#define OPTION_FORMAT_list "%s"
|
||||
#define OPTION_FORMAT_list "%s"
|
||||
|
||||
#define DEFINE_OPTION(_section, _name, _type) \
|
||||
{ \
|
||||
|
Loading…
x
Reference in New Issue
Block a user