Fixed that warnings that showed up with optimisations.

This commit is contained in:
Scott Anderson 2017-07-11 00:14:55 +12:00
parent be064df25e
commit 8189c64d7f
5 changed files with 15 additions and 11 deletions

View File

@ -1,11 +1,8 @@
/* GIMP RGBA C-Source image dump (cat.c) */ /* GIMP RGBA C-Source image dump (cat.c) */
const struct { #include "cat.h"
unsigned int width;
unsigned int height; const struct gimp_texture cat_tex = {
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[128 * 128 * 4 + 1];
} cat_tex = {
128, 128, 4, 128, 128, 4,
"[\227\017\377L\206\001\377M\212\002\377T\227\011\377V\231\010\377W\224\001\377[\222" "[\227\017\377L\206\001\377M\212\002\377T\227\011\377V\231\010\377W\224\001\377[\222"
"\001\377T\212\001\377P\211\001\377M\203\001\377P\212\001\377Q\217\001\377K\210\001\377" "\001\377T\212\001\377P\211\001\377M\203\001\377P\212\001\377Q\217\001\377K\210\001\377"

View File

@ -5,7 +5,7 @@ struct gimp_texture {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */ unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[128 * 128 * 3 + 1]; unsigned char pixel_data[128 * 128 * 4 + 1];
}; };
extern const struct gimp_texture cat_tex; extern const struct gimp_texture cat_tex;

View File

@ -192,7 +192,7 @@ static void parse_args(int argc, char *argv[], struct wl_list *config) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
struct sample_state state = { 0 }; struct sample_state state = {0};
wl_list_init(&state.config); wl_list_init(&state.config);
parse_args(argc, argv, &state.config); parse_args(argc, argv, &state.config);

View File

@ -5,6 +5,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/util/log.h>
struct pixel_format { struct pixel_format {
uint32_t wl_format; uint32_t wl_format;
@ -41,7 +42,7 @@ extern const GLchar fragment_src_rgbx[];
bool _gles2_flush_errors(const char *file, int line); bool _gles2_flush_errors(const char *file, int line);
#define gles2_flush_errors(...) \ #define gles2_flush_errors(...) \
_gles2_flush_errors(__FILE__ + strlen(WLR_SRC_DIR) + 1, __LINE__) _gles2_flush_errors(_strip_path(__FILE__), __LINE__)
#define GL_CALL(func) func; gles2_flush_errors() #define GL_CALL(func) func; gles2_flush_errors()

View File

@ -1,6 +1,8 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -62,7 +64,7 @@ static void send_msg(int sock, int fd, void *buf, size_t buf_len) {
.cmsg_type = SCM_RIGHTS, .cmsg_type = SCM_RIGHTS,
.cmsg_len = CMSG_LEN(sizeof(fd)), .cmsg_len = CMSG_LEN(sizeof(fd)),
}; };
*(int *)CMSG_DATA(cmsg) = fd; memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
} }
ssize_t ret; ssize_t ret;
@ -93,7 +95,11 @@ static ssize_t recv_msg(int sock, int *fd_out, void *buf, size_t buf_len) {
if (fd_out) { if (fd_out) {
struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msghdr); struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msghdr);
*fd_out = cmsg ? *(int *)CMSG_DATA(cmsg) : -1; if (cmsg) {
memcpy(fd_out, CMSG_DATA(cmsg), sizeof(*fd_out));
} else {
*fd_out = -1;
}
} }
return ret; return ret;