Skip to content

Commit

Permalink
Delint with -Wextra flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed Dec 27, 2024
1 parent 1a1f5ff commit d5bfdaa
Show file tree
Hide file tree
Showing 38 changed files with 105 additions and 66 deletions.
3 changes: 2 additions & 1 deletion aprsfeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int main(int argc,char *argv[]){
*cp++ = ':'; sspace--;
assert(sspace > 0);
}
for(int i=0; i < frame.info_len; i++){
for(size_t i=0; i < frame.info_len; i++){
char const c = frame.information[i] & 0x7f; // Strip parity in monitor strings
if(c != '\r' && c != '\n' && c != '\0'){
// Strip newlines, returns and nulls (we'll add a cr-lf later)
Expand Down Expand Up @@ -304,6 +304,7 @@ int main(int argc,char *argv[]){
// Just read and echo responses from server
void *netreader(void *arg){
pthread_setname("aprs-read");
(void)arg; // Not used

char *line = NULL;
size_t linecap = 0;
Expand Down
2 changes: 1 addition & 1 deletion avahi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <arpa/inet.h>
#include "avahi.h"

int avahi_start(char const *service_name,char const *service_type,int const service_port,char const *dns_name,int address,char const *description,void *sock,int *socksize){
int avahi_start(char const *service_name,char const *service_type,int const service_port,char const *dns_name,int address,char const *description,void *sock,size_t *socksize){
if(sock != NULL && socksize != NULL){
// Return sockaddr structure
if(*socksize >= sizeof(struct sockaddr_in)){
Expand Down
2 changes: 1 addition & 1 deletion avahi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ struct service_tab {
int avahi_browse(struct service_tab *table,int tabsize,char const *service_name);
void avahi_free_service_table(struct service_tab *table,int tabsize);

int avahi_start(char const *service_name,char const *service_type,int service_port,char const *dns_name,int base_address,char const *description,void *,int *);
int avahi_start(char const *service_name,char const *service_type,int service_port,char const *dns_name,int base_address,char const *description,void *,size_t *);
#define AVAHI_H 1
#endif
2 changes: 1 addition & 1 deletion ax25.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ax25_frame {
int control;
int type;
char information[MAX_INFO];
int info_len;
size_t info_len;
};


Expand Down
20 changes: 11 additions & 9 deletions control.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ static void display_input(WINDOW *input,struct channel const *channel);
static void display_output(WINDOW *output,struct channel const *channel);
static int process_keyboard(struct channel *,uint8_t **bpp,int c);
static void process_mouse(struct channel *channel,uint8_t **bpp);
static bool for_us(struct channel *channel,uint8_t const *buffer,int length,uint32_t ssrc);
static bool for_us(uint8_t const *buffer,int length,uint32_t ssrc);
static int init_demod(struct channel *channel);

// Fill in set of locally generated variables from channel structure
static void gen_locals(struct frontend *frontend,struct channel *channel){
static void gen_locals(struct channel *channel){
Local.noise_bandwidth = fabsf(channel->filter.max_IF - channel->filter.min_IF);
Local.sig_power = channel->sig.bb_power - Local.noise_bandwidth * channel->sig.n0;
if(Local.sig_power < 0)
Expand All @@ -121,7 +121,7 @@ static void popup(char const *filename){
if(fp == NULL)
return;
// Determine size of box
int rows=0, cols=0;
size_t rows=0, cols=0;
char *line = NULL;
size_t maxcols = 0;
while(getline(&line,&maxcols,fp) > 0){
Expand Down Expand Up @@ -290,13 +290,13 @@ static void setup_windows(void){
LINES = w.ws_row;

// Delete all previous windows
for(int i=0; i < NWINS; i++){
for(unsigned i=0; i < NWINS; i++){
if(*Windefs[i].w)
delwin(*Windefs[i].w);
*Windefs[i].w = NULL;
}
// Create as many as will fit
for(int i=0; i < NWINS; i++){
for(unsigned i=0; i < NWINS; i++){
if(COLS < col + Windefs[i].cols){
// No more room on this line, go to next
col = 0;
Expand Down Expand Up @@ -531,7 +531,7 @@ int main(int argc,char *argv[]){
continue;

char const *ip_addr_string = formatsock(&channel->output.dest_socket);
gen_locals(&Frontend,channel);
gen_locals(channel);
fprintf(stdout,"%13u %9s %'13.f %5.1f %s\n",channel->output.rtp.ssrc,channel->preset,channel->tune.freq,Local.snr,ip_addr_string);
last_ssrc = channel->output.rtp.ssrc;
}
Expand Down Expand Up @@ -615,7 +615,7 @@ int main(int argc,char *argv[]){
socklen_t ssize = sizeof(source_socket);
length = recvfrom(Status_fd,buffer,sizeof(buffer),0,(struct sockaddr *)&source_socket,&ssize); // should not block
// Ignore our own command packets and responses to other SSIDs
if(length < 2 || (enum pkt_type)buffer[0] != STATUS || !for_us(channel,buffer+1,length-1,Ssrc))
if(length < 2 || (enum pkt_type)buffer[0] != STATUS || !for_us(buffer+1,length-1,Ssrc))
continue; // Can include a timeout

// Process only if it's a response to our SSRC
Expand All @@ -625,7 +625,7 @@ int main(int argc,char *argv[]){
wprintw(Debug_win,"got response length %d\n",length);
#endif
decode_radio_status(&Frontend,channel,buffer+1,length-1);
gen_locals(&Frontend,channel);
gen_locals(channel);

// Postpone next poll to specified interval
next_radio_poll = now + radio_poll_interval + arc4random_uniform(random_interval) - random_interval/2;
Expand Down Expand Up @@ -1104,7 +1104,7 @@ static int init_demod(struct channel *channel){
}

// Is response for us?
static bool for_us(struct channel *channel,uint8_t const *buffer,int length,uint32_t ssrc){
static bool for_us(uint8_t const *buffer,int length,uint32_t ssrc){
uint8_t const *cp = buffer;

while(cp - buffer < length){
Expand Down Expand Up @@ -1412,6 +1412,8 @@ static void display_demodulator(WINDOW *w,struct channel const *channel){
if(channel->spectrum.bin_data != NULL)
pprintw(w,row++,col,"Bin 0","%.1f ",channel->spectrum.bin_data[0]);
break;
default:
break;
}

if(!isnan(channel->tp1))
Expand Down
3 changes: 2 additions & 1 deletion filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ struct filter_out *create_filter_output(struct filter_out *slave,struct filter_i
void *run_fft(void *p){
pthread_detach(pthread_self());
pthread_setname("fft");
(void)p; // Unused

realtime();

Expand Down Expand Up @@ -881,7 +882,7 @@ int window_rfilter(int const L,int const M,complex float * const response,float
}

// Gain of filter (output / input) on uniform gaussian noise
float const noise_gain(struct filter_out const * const slave){
float noise_gain(struct filter_out const * const slave){
if(slave == NULL)
return NAN;
struct filter_in const * const master = slave->master;
Expand Down
2 changes: 1 addition & 1 deletion filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int delete_filter_input(struct filter_in * restrict);
int delete_filter_output(struct filter_out * restrict);
int make_kaiser(float * restrict,int M,float);
int set_filter(struct filter_out * restrict,float,float,float);
float const noise_gain(struct filter_out const * restrict);
float noise_gain(struct filter_out const * restrict);
void *run_fft(void *);
int write_cfilter(struct filter_in *, complex float const *,int size);
int write_rfilter(struct filter_in *, float const *,int size);
Expand Down
4 changes: 3 additions & 1 deletion hid-libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ int hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int mi
pthread_mutex_lock(&dev->mutex);
pthread_cleanup_push(&cleanup_mutex, dev);


/* There's an input report queued up. Return it. */
if (dev->input_reports) {
/* Return the first one */
Expand Down Expand Up @@ -1222,7 +1223,8 @@ int hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string,

const wchar_t * hid_error(hid_device *dev)
{
return NULL;
(void)dev;
return NULL;
}


Expand Down
2 changes: 1 addition & 1 deletion iir.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline void reset_goertzel(struct goertzel *gp){
gp->s0 = gp->s1 = 0;
}

static void inline update_goertzel(struct goertzel *gp,float x){
inline static void update_goertzel(struct goertzel *gp,float x){
float s0save = gp->s0;
gp->s0 = x + gp->coeff * gp->s0 - gp->s1;
gp->s1 = s0save;
Expand Down
9 changes: 4 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ int main(int argc,char *argv[]){
case 'I':
dump_interfaces();
break;
default:
default: // including 'h'
fprintf(stdout,"Unknown command line option %c\n",c);
case 'h':
fprintf(stderr,"Usage: %s [-I] [-N name] [-h] [-p fftw_plan_time_limit] [-v [-v] ...] <CONFIG_FILE>\n", argv[0]);
exit(EX_USAGE);
}
Expand Down Expand Up @@ -315,7 +314,7 @@ static int loadconfig(char const * const file){
char ttlmsg[100];
snprintf(ttlmsg,sizeof(ttlmsg),"TTL=%d",Mcast_ttl);

int slen = sizeof(Template.output.dest_socket);
size_t slen = sizeof(Template.output.dest_socket);
uint32_t addr = make_maddr(Data);
avahi_start(Name,"_rtp._udp",DEFAULT_RTP_PORT,Data,addr,ttlmsg,&Template.output.dest_socket,&slen);
avahi_start(Name,"_opus._udp",DEFAULT_RTP_PORT,Data,addr,ttlmsg,&Template.output.dest_socket,&slen);
Expand Down Expand Up @@ -394,7 +393,7 @@ static int loadconfig(char const * const file){
{
char ttlmsg[100];
snprintf(ttlmsg,sizeof(ttlmsg),"TTL=%d",Mcast_ttl);
int slen = sizeof(Metadata_dest_socket);
size_t slen = sizeof(Metadata_dest_socket);
uint32_t addr = make_maddr(Metadata_dest_string);
avahi_start(Frontend.description != NULL ? Frontend.description : Name,"_ka9q-ctl._udp",DEFAULT_STAT_PORT,Metadata_dest_string,addr,ttlmsg,&Metadata_dest_socket,&slen);
}
Expand Down Expand Up @@ -457,7 +456,7 @@ static int loadconfig(char const * const file){
char ttlmsg[100];
snprintf(ttlmsg,sizeof(ttlmsg),"TTL=%d",Mcast_ttl);

int slen = sizeof(data_dest_socket);
size_t slen = sizeof(data_dest_socket);
uint32_t addr = make_maddr(data);

// Start only one depending on chan->output.encoding
Expand Down
1 change: 1 addition & 0 deletions metadump.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void usage(void){

// Process incoming packets
void *input_thread(void *p){
(void)p; // unused
for(int i=0; i < Count;){
uint8_t buffer[PKTSIZE];
struct sockaddr_storage source;
Expand Down
3 changes: 2 additions & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ char *ftime(char * result,int size,int64_t t){
double parse_frequency(char const *s,bool heuristics){
char * const ss = alloca(strlen(s)+1);
{
int i;
size_t i;
for(i=0;i<strlen(s);i++)
ss[i] = tolower(s[i]);

Expand Down Expand Up @@ -451,6 +451,7 @@ uint32_t fnv1hash(const uint8_t *s,int length){

int pthread_barrier_init(pthread_barrier_t *barrier, pthread_barrierattr_t const *attr, unsigned int count)
{
(void)attr;
if(count == 0)
{
errno = EINVAL;
Expand Down
18 changes: 9 additions & 9 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,44 +153,44 @@ float xi(float thetasq);
float fm_snr(float r);

// Convert floating point sample to 16-bit integer, with clipping
static int16_t inline scaleclip(float const x){
inline static int16_t scaleclip(float const x){
return (x >= 1.0) ? INT16_MAX : (x <= -1.0) ? -INT16_MAX : (int16_t)(INT16_MAX * x);
}
static inline complex float const csincosf(float const x){
static inline complex float csincosf(float const x){
float s,c;

sincosf(x,&s,&c);
return CMPLXF(c,s);
}
static inline complex float const csincospif(float const x){
static inline complex float csincospif(float const x){
float s,c;
sincospif(x,&s,&c);
return CMPLXF(c,s);
}
// return unit magnitude complex number with given phase x
static inline complex double const csincos(double const x){
static inline complex double csincos(double const x){
double s,c;

sincos(x,&s,&c);
return CMPLX(c,s);
}
static inline complex double const csincospi(double const x){
static inline complex double csincospi(double const x){
double s,c;
sincospi(x,&s,&c);
return CMPLX(c,s);
}
// Complex norm (sum of squares of real and imaginary parts)
static inline float const cnrmf(complex float const x){
static inline float cnrmf(complex float const x){
return crealf(x)*crealf(x) + cimagf(x) * cimagf(x);
}
static inline double const cnrm(complex double const x){
static inline double cnrm(complex double const x){
return creal(x)*creal(x) + cimag(x) * cimag(x);
}
// Fast approximate square root, for signal magnitudes
// https://dspguru.com/dsp/tricks/magnitude-estimator/
static inline float approx_magf(complex float x){
const static float Alpha = 0.947543636291;
const static float Beta = 0.392485425092;
static float const Alpha = 0.947543636291;
static float const Beta = 0.392485425092;

float absr = fabsf(__real__ x);
float absi = fabsf(__imag__ x);
Expand Down
5 changes: 2 additions & 3 deletions modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct demodtab Demodtab[] = {
{WFM_DEMOD, "WFM", }, // NBFM and noncoherent PM
{SPECT_DEMOD, "Spectrum", }, // Spectrum analysis
};
int Ndemod = sizeof(Demodtab)/sizeof(struct demodtab);

static enum demod_type DEFAULT_DEMOD = LINEAR_DEMOD;
static int const DEFAULT_LINEAR_SAMPRATE = 12000;
Expand Down Expand Up @@ -56,7 +55,7 @@ extern int Overlap;


int demod_type_from_name(char const *name){
for(int n = 0; n < Ndemod; n++){
for(enum demod_type n = 0; n < N_DEMOD; n++){
if(strncasecmp(name,Demodtab[n].name,sizeof(Demodtab[n].name)) == 0)
return Demodtab[n].type;
}
Expand All @@ -65,7 +64,7 @@ int demod_type_from_name(char const *name){


char const *demod_name_from_type(enum demod_type type){
if(type >= 0 && type < Ndemod)
if(type >= 0 && type < N_DEMOD)
return Demodtab[type].name;
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion monitor-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void *decode_task(void *arg){
// beginning of talk spurt, resync
reset_session(sp,pkt->rtp.timestamp); // Updates sp->wptr
}
if(pkt->rtp.type >= 0 && pkt->rtp.type < 128)
if(pkt->rtp.type < 128)
sp->type = pkt->rtp.type; // Save only if valid

enum encoding const encoding = sp->pt_table[sp->type].encoding;
Expand Down
6 changes: 3 additions & 3 deletions monitor-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int printwt(char const *fmt,...){

// Same for mvaddstr() and addstr()
int mvaddstrt(int y,int x,char const *str){
int space = COLS - x - 1; // Leave last column open
size_t space = COLS - x - 1; // Leave last column open
if(strlen(str) <= space)
return mvaddstr(y,x,str); // fits
char temp[space+1];
Expand All @@ -114,7 +114,7 @@ int mvaddstrt(int y,int x,char const *str){
int addstrt(char const *str){
int y,x;
getyx(stdscr,y,x);
int space = COLS - x - 1; // Leave last column open
size_t space = COLS - x - 1; // Leave last column open
if(strlen(str) <= space)
return mvaddstr(y,x,str); // fits
char temp[space+1];
Expand All @@ -125,8 +125,8 @@ int addstrt(char const *str){

// Use ncurses to display streams
void *display(void *arg){

pthread_setname("display");
(void)arg; // unused

if(initscr() == NULL){
fprintf(stderr,"initscr() failed, disabling control/display thread\n");
Expand Down
1 change: 1 addition & 0 deletions monitor-repeater.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void send_cwid(void){
// Drop PTT some time after last write to audio output ring buffer
void *repeater_ctl(void *arg){
pthread_setname("rptctl");
(void)arg; // unused

while(!Terminate){
// Wait for audio output; set in kick_output()
Expand Down
9 changes: 9 additions & 0 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ static struct option Options[] = {
#ifdef __linux__
// Get rid of those fucking ALSA error messages that clutter the screen
static void alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...){
(void)file; // no args used
(void)line;
(void)function;
(void)err;
(void)fmt;

return;
}
#endif
Expand Down Expand Up @@ -598,6 +604,9 @@ int pa_callback(void const *inputBuffer, void *outputBuffer,
PaStreamCallbackTimeInfo const * timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData){
(void)inputBuffer; // Unused
(void)statusFlags;
(void)userData;
Audio_callbacks++;
Audio_frames += framesPerBuffer;

Expand Down
2 changes: 1 addition & 1 deletion multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static struct inverse_cache *Inverse_cache_table; // Head of cache linked list
// so to make it easier for callers we just take a void * and avoid pointer casts that impair readability
char const *formatsock(void const *s){
// Determine actual length (and type) of binary socket structure (IPv4/IPv6)
int slen = 0;
size_t slen = 0;
struct sockaddr const * const sa = (struct sockaddr *)s;
if(sa == NULL)
return NULL;
Expand Down
Loading

0 comments on commit d5bfdaa

Please sign in to comment.