Browse Source

use c17 std, fix warnings / errors

master
Stefan Bühler 3 months ago
parent
commit
187ec1a68e
  1. 6
      meson.build
  2. 9
      src/announce.c
  3. 6
      src/bomber.c
  4. 2
      src/game.c
  5. 2
      src/gfx.c
  6. 2
      src/gfx.h
  7. 2
      src/list.c
  8. 17
      src/list.h
  9. 4
      src/network.c
  10. 1
      src/sound.c

6
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,

9
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);

6
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);

2
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) {

2
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;

2
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);

2
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);
}

17
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)

4
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) {

1
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)
{

Loading…
Cancel
Save