diff --git a/meson.build b/meson.build index b7993f0..46ca6e6 100644 --- a/meson.build +++ b/meson.build @@ -28,9 +28,9 @@ executable( 'src/network.c', 'src/sound.c', 'src/utils.c', - # override_options: [ - # 'c_std=c11', - # ], + override_options: [ + 'c_std=c17', + ], install: true, dependencies: [ avahi_client_dep, diff --git a/src/announce.c b/src/announce.c index ce3e63b..226c6cc 100644 --- a/src/announce.c +++ b/src/announce.c @@ -38,7 +38,7 @@ gamelistentry gamelistentries[10]; int gamelistsize = 0; static void myerror(AvahiClient *c, const char *s) { - fprintf(stderr, "Error in: %s\n (%s)", s, avahi_strerror(avahi_client_errno(client))); + fprintf(stderr, "Error in: %s\n (%s)", s, avahi_strerror(avahi_client_errno(c))); } static void create_services(AvahiClient *c); @@ -119,6 +119,8 @@ fail: } static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { + (void)userdata; + client = c; switch (state) { case AVAHI_CLIENT_S_RUNNING: @@ -183,6 +185,10 @@ static void resolve_callback(AvahiServiceResolver *r, AvahiIfIndex interface, Av uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void* userdata) { int i; uint32_t want_version; + (void)interface; + (void)host_name; + (void)flags; + (void)userdata; assert(r); if (protocol != AVAHI_PROTO_INET) goto done; /* ignore non IPv4 for now */ @@ -229,6 +235,7 @@ done: static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata) { + (void)flags; assert(b); diff --git a/src/bomber.c b/src/bomber.c index 9315d19..134060a 100644 --- a/src/bomber.c +++ b/src/bomber.c @@ -20,16 +20,16 @@ #include "game.h" #include "draw.h" -int main(int argc,char **argv) { +int main(void) { char *p; strcpy(playername,"ANONYMOUS"); p=getenv("USER"); - if(p) strncpy(playername,p,sizeof(playername)); + if(p) strncpy(playername,p,sizeof(playername)-1); create_seed_unique(); - opengfx(argc, argv); + opengfx(); getsocket(); if (!initannouncer()) exit(1); diff --git a/src/game.c b/src/game.c index ab27fda..c2b22a8 100644 --- a/src/game.c +++ b/src/game.c @@ -587,7 +587,7 @@ static void drawstats(void) { player *pl; int p = 0; const char *n; - char buf[16]; + char buf[17]; solidcopy(&background, 0, 0, IXSIZE, arraystarty); list_for_each_entry(pl, &allplayers, list_all_players) { diff --git a/src/gfx.c b/src/gfx.c index 3eb0c14..fd65dc9 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -407,7 +407,7 @@ void copyupxysize(int x,int y,int xsize,int ysize) // themap[color].b=blue; // } -void opengfx(int argc, char **argv) { +void opengfx(void) { unsigned long videoflags; themap[0].r=0; diff --git a/src/gfx.h b/src/gfx.h index 37a5533..771e5c5 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -19,7 +19,7 @@ extern int mxpos,mypos; extern int pressedcodes[KEYMAX],downcodes[KEYMAX],numpressed,numdown; -void opengfx(int argc, char **argv); +void opengfx(void); void gfxlock(void); void gfxunlock(void); void pollinput(void); diff --git a/src/list.c b/src/list.c index 9baa1a9..363148a 100644 --- a/src/list.c +++ b/src/list.c @@ -81,7 +81,7 @@ void things_list_clear(listhead *head) { genericlistitem *entry; while (head->next != head) { - entry = container_of(head->next, typeof(*entry), list); + entry = container_of(head->next, __typeof__(*entry), list); list_del(head->next); freeentry(entry); } diff --git a/src/list.h b/src/list.h index e1c2f56..450ed60 100644 --- a/src/list.h +++ b/src/list.h @@ -1,11 +1,10 @@ #ifndef LIST_H #define LIST_H -/* from linux kernel */ +/* from linux kernel (with some changes for "iso" c) */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) \ + ((type *)( (char *)(__typeof__( ((type *)0)->member ) *)(ptr) - offsetof(type,member))) /** * list_entry - get the struct for this entry @@ -38,10 +37,10 @@ void things_list_clear(listhead *head); /* listhead member must be the first mem * @member: the name of the list_struct within the struct. */ #define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ + for (pos = list_entry((head)->next, __typeof__(*pos), member); \ /* prefetch(pos->member.next), */ \ &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) + pos = list_entry(pos->member.next, __typeof__(*pos), member)) /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry @@ -51,10 +50,10 @@ void things_list_clear(listhead *head); /* listhead member must be the first mem * @member:>the name of the list_struct within the struct. */ #define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ + for (pos = list_entry((head)->next, __typeof__(*pos), member), \ + n = list_entry(pos->member.next, __typeof__(*pos), member); \ &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) + pos = n, n = list_entry(n->member.next, __typeof__(*n), member)) #define list_empty(head) ((head) == (head)->next) diff --git a/src/network.c b/src/network.c index e11bbc3..27e8a4f 100644 --- a/src/network.c +++ b/src/network.c @@ -473,7 +473,7 @@ static void send_reject(struct sockaddr_in *toname, Uint32 network_join_unique, memcpy(mesg+1, &network_join_unique, sizeof(network_join_unique)); write_version(mesg+5); mesg[9] = reason; - putmsg(&sender,mesg,10); + putmsg(toname,mesg,10); } static void send_accept(Uint32 network_join_unique) { @@ -526,7 +526,7 @@ int handle_joins() { int size; int i, j; unsigned char temp[64]; - Uint32 network_join_unique; + Uint32 network_join_unique = 0; size=getmsg(40); switch (*mesg) { diff --git a/src/sound.c b/src/sound.c index 642d2e6..06dc3d1 100644 --- a/src/sound.c +++ b/src/sound.c @@ -58,6 +58,7 @@ static void fillaudio(void *udata,Uint8 *buffer,int len) char com,*p; int i,j,*ip; int which; + (void)udata; while(soundtake!=soundput) {