mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-gtk
synced 2026-02-04 13:01:52 +00:00
Add printf format annotations to all '...' functions
To allow the compile to detect incorrect printf formats, any var-args function should have a format annotation * common/macros.h: Helper to define ATTR_PRINTF for code which can't depend on glib * common/canvas_base.c, common/lz.h, common/macros.h: Annotate some var-args methods
This commit is contained in:
parent
34ccd7e4ba
commit
75c9e2f679
@ -1764,7 +1764,7 @@ static pixman_image_t *canvas_scale_surface(pixman_image_t *src, const SpiceRect
|
||||
return surface;
|
||||
}
|
||||
|
||||
static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
|
||||
ATTR_PRINTF(2, 3) static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
|
||||
{
|
||||
QuicData *usr_data = (QuicData *)usr;
|
||||
va_list ap;
|
||||
@ -1776,7 +1776,7 @@ static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
|
||||
longjmp(usr_data->jmp_env, 1);
|
||||
}
|
||||
|
||||
static void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
|
||||
ATTR_PRINTF(2, 3) static void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
|
||||
{
|
||||
QuicData *usr_data = (QuicData *)usr;
|
||||
va_list ap;
|
||||
@ -1796,7 +1796,7 @@ static void quic_usr_free(QuicUsrContext *usr, void *ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
|
||||
ATTR_PRINTF(2, 3) static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
|
||||
{
|
||||
LzData *usr_data = (LzData *)usr;
|
||||
va_list ap;
|
||||
@ -1806,7 +1806,7 @@ static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
|
||||
ATTR_PRINTF(2, 3) static void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
|
||||
{
|
||||
LzData *usr_data = (LzData *)usr;
|
||||
va_list ap;
|
||||
|
||||
@ -9,14 +9,15 @@
|
||||
#include "lz_common.h"
|
||||
#include "lz_config.h"
|
||||
#include "draw.h"
|
||||
#include "macros.h"
|
||||
|
||||
typedef void *LzContext;
|
||||
|
||||
typedef struct LzUsrContext LzUsrContext;
|
||||
struct LzUsrContext {
|
||||
void (*error)(LzUsrContext *usr, const char *fmt, ...);
|
||||
void (*warn)(LzUsrContext *usr, const char *fmt, ...);
|
||||
void (*info)(LzUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*error)(LzUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*warn)(LzUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*info)(LzUsrContext *usr, const char *fmt, ...);
|
||||
void *(*malloc)(LzUsrContext *usr, int size);
|
||||
void (*free)(LzUsrContext *usr, void *ptr);
|
||||
int (*more_space)(LzUsrContext *usr, uint8_t **io_ptr); // get the next chunk of the
|
||||
|
||||
30
common/macros.h
Normal file
30
common/macros.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
Copyright (C) 2009 Red Hat, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MACROS_H
|
||||
#define __MACROS_H
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
#define ATTR_PRINTF(a,b) \
|
||||
__attribute__((format(printf,a,b)))
|
||||
#else
|
||||
#define ATTR_PRINTF(a,b)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
#endif /* __MACROS_H */
|
||||
@ -20,6 +20,7 @@
|
||||
#define __QUIC_H
|
||||
|
||||
#include "quic_config.h"
|
||||
#include "macros.h"
|
||||
|
||||
typedef enum {
|
||||
QUIC_IMAGE_TYPE_INVALID,
|
||||
@ -37,9 +38,9 @@ typedef void *QuicContext;
|
||||
|
||||
typedef struct QuicUsrContext QuicUsrContext;
|
||||
struct QuicUsrContext {
|
||||
void (*error)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
void (*warn)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
void (*info)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*error)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*warn)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
ATTR_PRINTF(2, 3) void (*info)(QuicUsrContext *usr, const char *fmt, ...);
|
||||
void *(*malloc)(QuicUsrContext *usr, int size);
|
||||
void (*free)(QuicUsrContext *usr, void *ptr);
|
||||
int (*more_space)(QuicUsrContext *usr, uint32_t **io_ptr, int rows_completed);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user