Skip to content

Commit 04e48d8

Browse files
committed
Fix warnings in event, camera and display
1 parent 81b228c commit 04e48d8

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src_c/camera.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,25 @@
5858
#include <mftransform.h>
5959
#endif
6060

61+
#ifndef v4l2_fourcc
62+
/* Four-character-code (FOURCC), taken from v4l source */
63+
#define v4l2_fourcc(a, b, c, d) \
64+
((Uint32)(a) | ((Uint32)(b) << 8) | ((Uint32)(c) << 16) | \
65+
((Uint32)(d) << 24))
66+
#endif
67+
6168
/* some constants used which are not defined on non-v4l machines. */
6269
#ifndef V4L2_PIX_FMT_RGB24
63-
#define V4L2_PIX_FMT_RGB24 'RGB3'
70+
#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3')
6471
#endif
6572
#ifndef V4L2_PIX_FMT_RGB444
66-
#define V4L2_PIX_FMT_RGB444 'R444'
73+
#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4')
6774
#endif
6875
#ifndef V4L2_PIX_FMT_YUYV
69-
#define V4L2_PIX_FMT_YUYV 'YUYV'
76+
#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')
7077
#endif
7178
#ifndef V4L2_PIX_FMT_XBGR32
72-
#define V4L2_PIX_FMT_XBGR32 'XR24'
79+
#define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4')
7380
#endif
7481

7582
#define CLEAR(x) memset(&(x), 0, sizeof(x))

src_c/display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
859859
int w, h;
860860
PyObject *size = NULL;
861861
int vsync = SDL_FALSE;
862-
uint64_t hwnd = 0;
862+
intptr_t hwnd = 0;
863863
/* display will get overwritten by ParseTupleAndKeywords only if display
864864
parameter is given. By default, put the new window on the same
865865
screen as the old one */
@@ -880,7 +880,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
880880
return NULL;
881881

882882
if (hwnd == 0 && winid_env != NULL) {
883-
hwnd = SDL_strtoull(winid_env, NULL, 0);
883+
hwnd = (intptr_t)SDL_strtoull(winid_env, NULL, 0);
884884
}
885885

886886
if (scale_env != NULL) {

src_c/event.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ _pg_put_event_unicode(SDL_Event *event, char *uni)
275275
static PyObject *
276276
_pg_get_event_unicode(SDL_Event *event)
277277
{
278-
char c;
278+
/* We only deal with one byte here, but still declare an array to silence
279+
* compiler warnings. The other 3 bytes are unused */
280+
char c[4];
279281
int i;
280282
for (i = 0; i < MAX_SCAN_UNICODE; i++) {
281283
if (scanunicode[i].key == event->key.keysym.scancode) {
@@ -289,8 +291,8 @@ _pg_get_event_unicode(SDL_Event *event)
289291
}
290292
/* fallback to function that determines unicode from the event.
291293
* We try to get the unicode attribute, and store it in memory*/
292-
c = _pg_unicode_from_event(event);
293-
if (_pg_put_event_unicode(event, &c))
294+
*c = _pg_unicode_from_event(event);
295+
if (_pg_put_event_unicode(event, c))
294296
return _pg_get_event_unicode(event);
295297
return PyUnicode_FromString("");
296298
}

0 commit comments

Comments
 (0)