Skip to content

Commit ba145c5

Browse files
committed
Fix warnings
Except for deps and the parts that are specifically pipewire includes, this compiles under pedantic and C89 for me on Linux. Mostly this was fixing issues, but in pipewire's case it involved ignoring some errors.
1 parent 6217684 commit ba145c5

File tree

23 files changed

+143
-84
lines changed

23 files changed

+143
-84
lines changed

Makefile.emscripten

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ endif
283283
ifeq ($(DEBUG), 1)
284284
LDFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=2 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1
285285
# -O0 in cflags gives "too many locals" errors
286-
CFLAGS += -O1 -g -gsource-map
286+
CFLAGS += -O1 -g -gsource-map -Wall -Werror
287287
else
288288
LDFLAGS += -O3
289289
# WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake)

audio/common/pipewire.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ static void core_error_cb(void *data, uint32_t id, int seq, int res, const char
2727
{
2828
pipewire_core_t *pw = (pipewire_core_t*)data;
2929

30+
#pragma GCC diagnostic push
31+
#pragma GCC diagnostic ignored "-Wpedantic"
3032
RARCH_ERR("[PipeWire] Error id:%u seq:%d res:%d (%s): %s.\n",
3133
id, seq, res, spa_strerror(res), message);
32-
34+
#pragma GCC diagnostic pop
3335
pw_thread_loop_stop(pw->thread_loop);
3436
}
3537

@@ -54,8 +56,10 @@ static const struct pw_core_events core_events = {
5456
void pipewire_core_wait_resync(pipewire_core_t *pw)
5557
{
5658
retro_assert(pw);
59+
#pragma GCC diagnostic push
60+
#pragma GCC diagnostic ignored "-Wpedantic"
5761
pw->pending_seq = pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq);
58-
62+
#pragma GCC diagnostic pop
5963
for (;;)
6064
{
6165
pw_thread_loop_wait(pw->thread_loop);
@@ -116,16 +120,21 @@ bool pipewire_core_init(pipewire_core_t **pw, const char *loop_name, const struc
116120
if (!(*pw)->core)
117121
goto unlock;
118122

123+
#pragma GCC diagnostic push
124+
#pragma GCC diagnostic ignored "-Wpedantic"
119125
if (pw_core_add_listener((*pw)->core,
120126
&(*pw)->core_listener,
121127
&core_events, *pw) < 0)
122128
goto unlock;
123-
129+
#pragma GCC diagnostic pop
124130
if (events)
125131
{
126132
(*pw)->registry = pw_core_get_registry((*pw)->core, PW_VERSION_REGISTRY, 0);
127133
spa_zero((*pw)->registry_listener);
134+
#pragma GCC diagnostic push
135+
#pragma GCC diagnostic ignored "-Wpedantic"
128136
pw_registry_add_listener((*pw)->registry, &(*pw)->registry_listener, events, *pw);
137+
#pragma GCC diagnostic pop
129138
}
130139

131140
return true;
@@ -138,7 +147,10 @@ bool pipewire_core_init(pipewire_core_t **pw, const char *loop_name, const struc
138147
void pipewire_core_deinit(pipewire_core_t *pw)
139148
{
140149
if (!pw)
141-
return pw_deinit();
150+
{
151+
pw_deinit();
152+
return;
153+
}
142154

143155
if (pw->thread_loop)
144156
pw_thread_loop_stop(pw->thread_loop);

audio/common/pipewire.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
#define _RETROARCH_PIPEWIRE
1919

2020
#include <stdint.h>
21-
21+
#pragma GCC diagnostic push
22+
#pragma GCC diagnostic ignored "-Wpedantic"
2223
#include <spa/param/audio/format-utils.h>
2324
#include <spa/utils/ringbuffer.h>
2425
#include <pipewire/pipewire.h>
26+
#pragma GCC diagnostic pop
2527

2628
#include <lists/string_list.h>
2729

audio/drivers/alsathread.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ static void alsa_microphone_worker_thread(void *mic_context)
212212
RARCH_DBG("[ALSA] [capture thread %p] Ending microphone worker thread.\n", thread_id);
213213
}
214214

215-
static int alsa_thread_microphone_read(void *driver_context, void *mic_context, void *s, size_t len)
215+
static int alsa_thread_microphone_read(void *driver_context, void *mic_context, void *sv, size_t len)
216216
{
217217
snd_pcm_state_t state;
218218
size_t _len = 0;
219+
uint8_t *s = (uint8_t *)sv;
219220
alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context;
220221
alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
221222

audio/drivers/pipewire.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
* You should have received a copy of the GNU General Public License along with RetroArch.
1313
* If not, see <http://www.gnu.org/licenses/>.
1414
*/
15-
15+
#pragma GCC diagnostic push
16+
#pragma GCC diagnostic ignored "-Wpedantic"
1617
#include <spa/param/audio/format-utils.h>
1718
#include <spa/utils/ringbuffer.h>
1819
#include <spa/utils/result.h>
1920
#include <spa/param/props.h>
2021
#include <pipewire/pipewire.h>
22+
#pragma GCC diagnostic pop
2123

2224
#include <boolean.h>
2325
#include <retro_miscellaneous.h>
@@ -132,12 +134,16 @@ static void pwire_capture_process_cb(void *data)
132134
if (!(b = pw_stream_dequeue_buffer(mic->stream)))
133135
{
134136
RARCH_ERR("[Microphone] [PipeWire] Out of buffers: %s.\n", strerror(errno));
135-
return pw_thread_loop_signal(mic->pw->thread_loop, false);
137+
pw_thread_loop_signal(mic->pw->thread_loop, false);
138+
return;
136139
}
137140

138141
buf = b->buffer;
139142
if ((p = buf->datas[0].data) == NULL)
140-
return pw_thread_loop_signal(mic->pw->thread_loop, false);
143+
{
144+
pw_thread_loop_signal(mic->pw->thread_loop, false);
145+
return;
146+
}
141147

142148
offs = MIN(buf->datas[0].chunk->offset, buf->datas[0].maxsize);
143149
n_bytes = MIN(buf->datas[0].chunk->size, buf->datas[0].maxsize - offs);
@@ -216,8 +222,10 @@ static void *pwire_microphone_init(void)
216222
struct pw_properties *props = NULL;
217223
const char *error = NULL;
218224
pipewire_core_t *pw = NULL;
225+
#pragma GCC diagnostic push
226+
#pragma GCC diagnostic ignored "-Wpedantic"
219227
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
220-
228+
#pragma GCC diagnostic pop
221229
if (!pipewire_core_init(&pw, "microphone_driver", &pwire_mic_registry_events))
222230
goto error;
223231

@@ -336,7 +344,10 @@ static void *pwire_microphone_open_mic(void *driver_context,
336344
const struct spa_pod *params[1];
337345
struct pw_properties *props = NULL;
338346
const char *error = NULL;
347+
#pragma GCC diagnostic push
348+
#pragma GCC diagnostic ignored "-Wpedantic"
339349
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
350+
#pragma GCC diagnostic pop
340351
pipewire_microphone_t *mic = NULL;
341352

342353
if (!driver_context || (mic = calloc(1, sizeof(pipewire_microphone_t))) == NULL)
@@ -494,12 +505,16 @@ static void pwire_playback_process_cb(void *data)
494505
if ((b = pw_stream_dequeue_buffer(audio->stream)) == NULL)
495506
{
496507
RARCH_WARN("[PipeWire] Out of buffers: %s.\n", strerror(errno));
497-
return pw_thread_loop_signal(audio->pw->thread_loop, false);
508+
pw_thread_loop_signal(audio->pw->thread_loop, false);
509+
return;
498510
}
499511

500512
buf = b->buffer;
501513
if ((p = buf->datas[0].data) == NULL)
502-
return pw_thread_loop_signal(audio->pw->thread_loop, false);
514+
{
515+
pw_thread_loop_signal(audio->pw->thread_loop, false);
516+
return;
517+
}
503518

504519
/* calculate the total no of bytes to read data from buffer */
505520
n_bytes = buf->datas[0].maxsize;
@@ -596,7 +611,10 @@ static void *pwire_init(const char *device, unsigned rate,
596611
struct pw_properties *props = NULL;
597612
const char *error = NULL;
598613
pipewire_audio_t *audio = (pipewire_audio_t*)calloc(1, sizeof(*audio));
614+
#pragma GCC diagnostic push
615+
#pragma GCC diagnostic ignored "-Wpedantic"
599616
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
617+
#pragma GCC diagnostic pop
600618

601619
if (!audio)
602620
return NULL;

audio/drivers/sdl_audio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,12 @@ static void sdl_microphone_set_nonblock_state(void *driver_context, bool state)
313313
sdl->nonblock = state;
314314
}
315315

316-
static int sdl_microphone_read(void *driver_context, void *mic_context, void *s, size_t len)
316+
static int sdl_microphone_read(void *driver_context, void *mic_context, void *sv, size_t len)
317317
{
318318
int ret = 0;
319319
sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context;
320320
sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context;
321+
uint8_t *s = (uint8_t *)sv;
321322

322323
if (!sdl || !mic || !s)
323324
return -1;

camera/drivers/pipewire.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* If not, see <http://www.gnu.org/licenses/>.
1414
*/
1515

16+
#pragma GCC diagnostic push
17+
#pragma GCC diagnostic ignored "-Wpedantic"
1618
#include <spa/utils/result.h>
1719
#include <spa/param/video/format-utils.h>
1820
#include <spa/param/tag-utils.h>
@@ -21,6 +23,7 @@
2123
#include <spa/debug/format.h>
2224
#include <spa/debug/pod.h>
2325
#include <pipewire/pipewire.h>
26+
#pragma GCC diagnostic pop
2427

2528
#include <gfx/scaler/scaler.h>
2629
#include <gfx/video_frame.h>
@@ -209,8 +212,10 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
209212
uint8_t params_buffer[1024];
210213
const struct spa_pod *params[5];
211214
pipewire_camera_t *camera = (pipewire_camera_t*)data;
215+
#pragma GCC diagnostic push
216+
#pragma GCC diagnostic ignored "-Wpedantic"
212217
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
213-
218+
#pragma GCC diagnostic pop
214219
if (param && id == SPA_PARAM_Tag)
215220
{
216221
spa_debug_pod(0, NULL, param);
@@ -258,6 +263,8 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
258263
return;
259264
}
260265

266+
#pragma GCC diagnostic push
267+
#pragma GCC diagnostic ignored "-Wpedantic"
261268
struct spa_pod_frame frame;
262269
spa_pod_builder_push_object(&b, &frame, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers);
263270
spa_pod_builder_add(&b,
@@ -270,7 +277,6 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
270277
0);
271278

272279
params[0] = spa_pod_builder_pop(&b, &frame);
273-
274280
params[1] = spa_pod_builder_add_object(&b,
275281
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
276282
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
@@ -281,6 +287,7 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
281287
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoTransform),
282288
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_videotransform)));
283289
#endif
290+
#pragma GCC diagnostic pop
284291

285292
camera->buffer_output = (uint32_t *)
286293
malloc(camera->size.width * camera->size.height * sizeof(uint32_t));
@@ -372,8 +379,11 @@ static void *pipewire_init(const char *device, uint64_t caps,
372379
struct pw_properties *props;
373380
uint8_t buffer[1024];
374381
pipewire_camera_t *camera = (pipewire_camera_t*)calloc(1, sizeof(*camera));
382+
#pragma GCC diagnostic push
383+
#pragma GCC diagnostic ignored "-Wpedantic"
375384
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
376-
385+
#pragma GCC diagnostic pop
386+
377387
if (!camera)
378388
goto error;
379389

@@ -420,7 +430,10 @@ static void *pipewire_init(const char *device, uint64_t caps,
420430

421431
if (res < 0)
422432
{
433+
#pragma GCC diagnostic push
434+
#pragma GCC diagnostic ignored "-Wpedantic"
423435
RARCH_ERR("[Camera] [PipeWire] Can't connect: %s.\n", spa_strerror(res));
436+
#pragma GCC diagnostic pop
424437
goto error;
425438
}
426439

command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ bool command_seek_replay(command_t *cmd, const char *arg)
826826
{
827827
_len = strlcpy(reply, "OK ", sizeof(reply));
828828
_len += snprintf(reply+_len, sizeof(reply)-_len,
829-
"%lld", input_st->bsv_movie_state.seek_target_frame);
829+
"%" PRId64, input_st->bsv_movie_state.seek_target_frame);
830830
}
831831
else
832832
_len = strlcpy(reply, "NO", sizeof(reply));

cores/libretro-ffmpeg/ffmpeg_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static video_buffer_t *video_buffer;
9898
static tpool_t *tpool;
9999

100100
#ifndef FFMPEG3
101-
#define FFMPEG3 ((LIBAVUTIL_VERSION_INT < (56, 6, 100)) || \
101+
#define FFMPEG3 ((LIBAVUTIL_VERSION_INT < AV_VERSION_INT(56, 6, 100)) || \
102102
(LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100)))
103103
#endif
104104
#ifndef FFMPEG8

cores/libretro-video-processor/video_processor_v4l2.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct v4l2_resolution
7878

7979
struct v4l2_resolution v4l2_resolutions[] =
8080
{
81-
//4:3
81+
/*4:3*/
8282
{160,120},
8383
{320,240},
8484
{480,320},
@@ -92,7 +92,7 @@ struct v4l2_resolution v4l2_resolutions[] =
9292
{1440,1080},
9393
{1600,1200},
9494
{1920,1440},
95-
//16:9
95+
/*16:9*/
9696
{640,360},
9797
{960,540},
9898
{1280,720},
@@ -291,7 +291,7 @@ static void enumerate_audio_devices(char *s, size_t len)
291291
continue;
292292
}
293293

294-
//todo: add more info to make picking audio device more user friendly
294+
/*todo: add more info to make picking audio device more user friendly*/
295295
descr = snd_device_name_get_hint(*n, "DESC");
296296
if (!descr)
297297
{
@@ -305,7 +305,7 @@ static void enumerate_audio_devices(char *s, size_t len)
305305
appendstr(s, name, len);
306306
++ndevs;
307307

308-
// not sure if this is necessary but ensuring things are free/null
308+
/* not sure if this is necessary but ensuring things are free/null*/
309309
if(name != NULL)
310310
{
311311
free(name);
@@ -593,6 +593,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst
593593
}
594594
else
595595
{
596+
bool nodouble;
596597
/*
597598
* Query the device cropping limits. If available, we can use this to find the capture pixel aspect.
598599
*/
@@ -618,14 +619,14 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst
618619
printf("Resolution postfix %ux%u\n", info->geometry.base_width,
619620
info->geometry.base_height);
620621
}
621-
// no doubling for interlaced or deinterlaced capture
622-
bool nodouble = strcmp(video_capture_mode, "deinterlaced") == 0 || strcmp(video_capture_mode, "interlaced") == 0;
622+
/* no doubling for interlaced or deinterlaced capture*/
623+
nodouble = strcmp(video_capture_mode, "deinterlaced") == 0 || strcmp(video_capture_mode, "interlaced") == 0;
623624
info->geometry.max_height = nodouble ? video_format.fmt.pix.height : video_format.fmt.pix.height * 2;
624625

625626
/* TODO Only double if frames ARE fields (progressive or deinterlaced, full framerate)
626627
* *2 for fields
627628
*/
628-
// defaulting to 60 if this this doesn't return a usable number
629+
/* defaulting to 60 if this this doesn't return a usable number*/
629630
if(video_standard.frameperiod.denominator == 0 || video_standard.frameperiod.numerator == 0)
630631
info->timing.fps = 60;
631632
else
@@ -1281,7 +1282,7 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in
12811282
fmt.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
12821283
fmt.fmt.pix.quantization = V4L2_QUANTIZATION_LIM_RANGE;
12831284

1284-
// applied set resolution if not set to auto
1285+
/* applied set resolution if not set to auto */
12851286
if (strcmp(video_capture_resolution, "auto") != 0)
12861287
{
12871288
strcpy(splitresolution, video_capture_resolution);

0 commit comments

Comments
 (0)