Skip to content

Commit

Permalink
build: Disable Wno-unused-parameter and wrap unused params in UNUSED
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindavi committed Nov 3, 2020
1 parent c72b561 commit 11a78a7
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 5 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" MATCHES
ADD_DEFINITIONS(-Wextra)
ADD_DEFINITIONS(-Wsign-compare)
ADD_DEFINITIONS(-Wno-unused)
ADD_DEFINITIONS(-Wno-unused-parameter)
ADD_DEFINITIONS(-Wno-missing-field-initializers)
ADD_DEFINITIONS(-std=c99)
ADD_DEFINITIONS(-pedantic)
Expand Down
8 changes: 8 additions & 0 deletions include/r_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
// buffer to hold localized timestamp "YYYY-MM-DD HH:MM:SS.000000+0000"
#define LOCAL_TIME_BUFLEN 32

// Macro to prevent unused variables (passed into a function)
// from generating a warning.
#define UNUSED(x) (void)(x)
// Macro to signal that that variable might not be used.
// Useful when a variable is used only in an ifdef block that may or
// may not be enabled.
#define POSSIBLY_UNUSED(x) (void)(x)

/** Get current time with usec precision.
@param tv output for current time
Expand Down
3 changes: 3 additions & 0 deletions src/baseband.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <string.h>
#include <math.h>

#include "r_util.h"

static uint16_t scaled_squares[256];

/// precalculate lookup table for envelope detection.
Expand Down Expand Up @@ -257,6 +259,7 @@ static int32_t atan2_int32(int32_t y, int32_t x)
/// for evaluation.
void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state, unsigned fpdm)
{
UNUSED(fpdm);
/// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples
//static int const alp[2] = {FIX32(1.00000), FIX32(0.72654)};
//static int const blp[2] = {FIX32(0.13673), FIX32(0.13673)};
Expand Down
15 changes: 15 additions & 0 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "term_ctl.h"
#include "abuf.h"
#include "fatal.h"
#include "r_util.h"

#include "data.h"

Expand Down Expand Up @@ -474,6 +475,7 @@ static void print_json_array(data_output_t *output, data_array_t *array, char co

static void print_json_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
bool separator = false;
fputc('{', output->file);
while (data) {
Expand All @@ -490,6 +492,7 @@ static void print_json_data(data_output_t *output, data_t *data, char const *for

static void print_json_string(data_output_t *output, const char *str, char const *format)
{
UNUSED(format);
fprintf(output->file, "\"");
while (*str) {
if (*str == '"' || *str == '\\')
Expand All @@ -502,11 +505,13 @@ static void print_json_string(data_output_t *output, const char *str, char const

static void print_json_double(data_output_t *output, double data, char const *format)
{
UNUSED(format);
fprintf(output->file, "%.3f", data);
}

static void print_json_int(data_output_t *output, int data, char const *format)
{
UNUSED(format);
fprintf(output->file, "%d", data);
}

Expand Down Expand Up @@ -588,6 +593,7 @@ typedef struct {

static void print_kv_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
data_output_kv_t *kv = (data_output_kv_t *)output;

int color = kv->color;
Expand Down Expand Up @@ -737,6 +743,7 @@ typedef struct {

static void print_csv_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
data_output_csv_t *csv = (data_output_csv_t *)output;

const char **fields = csv->fields;
Expand Down Expand Up @@ -782,6 +789,7 @@ static void print_csv_array(data_output_t *output, data_array_t *array, char con

static void print_csv_string(data_output_t *output, const char *str, char const *format)
{
UNUSED(format);
data_output_csv_t *csv = (data_output_csv_t *)output;

while (*str) {
Expand Down Expand Up @@ -879,11 +887,13 @@ static void data_output_csv_start(struct data_output *output, const char **field

static void print_csv_double(data_output_t *output, double data, char const *format)
{
UNUSED(format);
fprintf(output->file, "%.3f", data);
}

static void print_csv_int(data_output_t *output, int data, char const *format)
{
UNUSED(format);
fprintf(output->file, "%d", data);
}

Expand Down Expand Up @@ -937,6 +947,7 @@ static void format_jsons_array(data_output_t *output, data_array_t *array, char

static void format_jsons_object(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
data_print_jsons_t *jsons = (data_print_jsons_t *)output;

bool separator = false;
Expand All @@ -955,6 +966,7 @@ static void format_jsons_object(data_output_t *output, data_t *data, char const

static void format_jsons_string(data_output_t *output, const char *str, char const *format)
{
UNUSED(format);
data_print_jsons_t *jsons = (data_print_jsons_t *)output;

char *buf = jsons->msg.tail;
Expand Down Expand Up @@ -986,6 +998,7 @@ static void format_jsons_string(data_output_t *output, const char *str, char con

static void format_jsons_double(data_output_t *output, double data, char const *format)
{
UNUSED(format);
data_print_jsons_t *jsons = (data_print_jsons_t *)output;
// use scientific notation for very big/small values
if (data > 1e7 || data < 1e-4) {
Expand All @@ -1004,6 +1017,7 @@ static void format_jsons_double(data_output_t *output, double data, char const *

static void format_jsons_int(data_output_t *output, int data, char const *format)
{
UNUSED(format);
data_print_jsons_t *jsons = (data_print_jsons_t *)output;
abuf_printf(&jsons->msg, "%d", data);
}
Expand Down Expand Up @@ -1108,6 +1122,7 @@ typedef struct {

static void print_syslog_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
data_output_syslog_t *syslog = (data_output_syslog_t *)output;

// we expect a normal message around 500 bytes
Expand Down
4 changes: 2 additions & 2 deletions src/devices/m_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static void parse_payload(data_t *data, const m_bus_block1_t *block1, const m_bu
return;
}

static int parse_block2(r_device *decoder, const m_bus_data_t *in, m_bus_block1_t *block1)
static int parse_block2(const m_bus_data_t *in, m_bus_block1_t *block1)
{
m_bus_block2_t *b2 = &block1->block2;
const uint8_t *b = in->data+BLOCK1A_SIZE;
Expand Down Expand Up @@ -418,7 +418,7 @@ static int m_bus_decode_format_a(r_device *decoder, const m_bus_data_t *in, m_bu
memcpy(out_ptr, in_ptr, block_size);
}

parse_block2(decoder, in, block1);
parse_block2(in, block1);

return 1;
}
Expand Down
8 changes: 8 additions & 0 deletions src/output_influx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "optparse.h"
#include "util.h"
#include "fatal.h"
#include "r_util.h"

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -181,6 +182,8 @@ static void mbuf_remove_part(struct mbuf *a, char *pos, size_t len)

static void print_influx_array(data_output_t *output, data_array_t *array, char const *format)
{
UNUSED(array);
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
struct mbuf *buf = &influx->databufs[influx->databufidxfill];
mbuf_snprintf(buf, "\"array\""); // TODO
Expand All @@ -195,6 +198,7 @@ static void print_influx_data_escaped(data_output_t *output, data_t *data, char

static void print_influx_string_escaped(data_output_t *output, char const *str, char const *format)
{
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
struct mbuf *databuf = &influx->databufs[influx->databufidxfill];
size_t size = databuf->size - databuf->len;
Expand Down Expand Up @@ -225,6 +229,7 @@ static void print_influx_string_escaped(data_output_t *output, char const *str,

static void print_influx_string(data_output_t *output, char const *str, char const *format)
{
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
struct mbuf *buf = &influx->databufs[influx->databufidxfill];
mbuf_snprintf(buf, "%s", str);
Expand All @@ -233,6 +238,7 @@ static void print_influx_string(data_output_t *output, char const *str, char con
// Generate InfluxDB line protocol
static void print_influx_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
char *str;
char *end;
Expand Down Expand Up @@ -351,13 +357,15 @@ static void print_influx_data(data_output_t *output, data_t *data, char const *f

static void print_influx_double(data_output_t *output, double data, char const *format)
{
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
struct mbuf *buf = &influx->databufs[influx->databufidxfill];
mbuf_snprintf(buf, "%f", data);
}

static void print_influx_int(data_output_t *output, int data, char const *format)
{
UNUSED(format);
influx_client_t *influx = (influx_client_t *)output;
struct mbuf *buf = &influx->databufs[influx->databufidxfill];
mbuf_snprintf(buf, "%d", data);
Expand Down
3 changes: 3 additions & 0 deletions src/output_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "optparse.h"
#include "util.h"
#include "fatal.h"
#include "r_util.h"

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -304,6 +305,7 @@ static char *expand_topic(char *topic, char const *format, data_t *data, char co
// <prefix>[/type][/model][/subtype][/channel][/id]/battery: "OK"|"LOW"
static void print_mqtt_data(data_output_t *output, data_t *data, char const *format)
{
UNUSED(format);
data_output_mqtt_t *mqtt = (data_output_mqtt_t *)output;

char *orig = mqtt->topic + strlen(mqtt->topic); // save current topic
Expand Down Expand Up @@ -374,6 +376,7 @@ static void print_mqtt_data(data_output_t *output, data_t *data, char const *for

static void print_mqtt_string(data_output_t *output, char const *str, char const *format)
{
UNUSED(format);
data_output_mqtt_t *mqtt = (data_output_mqtt_t *)output;
mqtt_client_publish(mqtt->mqc, mqtt->topic, str);
}
Expand Down
2 changes: 1 addition & 1 deletion src/r_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ void add_syslog_output(r_cfg_t *cfg, char *param)

void add_null_output(r_cfg_t *cfg, char *param)
{
(void)param;
UNUSED(param);
list_push(&cfg->output_handler, NULL);
}

Expand Down
9 changes: 9 additions & 0 deletions src/sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct rtl_tcp_info {

static int rtltcp_open(sdr_dev_t **out_dev, int *sample_size, char *dev_query, int verbose)
{
UNUSED(verbose);
char *host = "localhost";
char *port = "1234";

Expand Down Expand Up @@ -268,6 +269,7 @@ static int rtltcp_close(SOCKET sock)

static int rtltcp_read_loop(sdr_dev_t *dev, sdr_event_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len)
{
UNUSED(buf_num);
if (dev->buffer_size != buf_len) {
free(dev->buffer);
dev->buffer = malloc(buf_len);
Expand Down Expand Up @@ -1229,6 +1231,8 @@ int sdr_set_tuner_gain(sdr_dev_t *dev, char const *gain_str, int verbose)

int sdr_set_antenna(sdr_dev_t *dev, char const *antenna_str, int verbose)
{
POSSIBLY_UNUSED(dev);
POSSIBLY_UNUSED(verbose);
int r = -1;

if (!antenna_str)
Expand Down Expand Up @@ -1315,6 +1319,8 @@ uint32_t sdr_get_sample_rate(sdr_dev_t *dev)

int sdr_apply_settings(sdr_dev_t *dev, char const *sdr_settings, int verbose)
{
POSSIBLY_UNUSED(dev);
POSSIBLY_UNUSED(verbose);
int r = -1;

if (!sdr_settings || !*sdr_settings)
Expand Down Expand Up @@ -1363,6 +1369,7 @@ int sdr_apply_settings(sdr_dev_t *dev, char const *sdr_settings, int verbose)

int sdr_activate(sdr_dev_t *dev)
{
POSSIBLY_UNUSED(dev);
#ifdef SOAPYSDR
if (dev->soapy_dev) {
if (SoapySDRDevice_activateStream(dev->soapy_dev, dev->soapy_stream, 0, 0, 0) != 0) {
Expand All @@ -1377,6 +1384,7 @@ int sdr_activate(sdr_dev_t *dev)

int sdr_deactivate(sdr_dev_t *dev)
{
POSSIBLY_UNUSED(dev);
#ifdef SOAPYSDR
if (dev->soapy_dev) {
SoapySDRDevice_deactivateStream(dev->soapy_dev, dev->soapy_stream, 0, 0);
Expand All @@ -1389,6 +1397,7 @@ int sdr_deactivate(sdr_dev_t *dev)

int sdr_reset(sdr_dev_t *dev, int verbose)
{
POSSIBLY_UNUSED(dev);
int r = 0;

#ifdef RTLSDR
Expand Down
2 changes: 1 addition & 1 deletion src/term_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void term_ring_bell(void *ctx)
{
#ifdef _WIN32
Beep(800, 20);
(void) ctx;
UNUSED(ctx);
#else
FILE *fp = (FILE *)ctx;
fprintf(fp, "\a");
Expand Down

0 comments on commit 11a78a7

Please sign in to comment.