[app] Fixed gcc 4.8 warning "iteration 1u invokes undefined behavior"

This commit is contained in:
Slava Monich 2015-10-15 17:20:52 +03:00
parent 88e439e170
commit 1fc46997eb
3 changed files with 33 additions and 33 deletions

View file

@ -70,6 +70,16 @@
(XML_Parser parser, const char* s, int len, int isFinal), \
(parser, s, len, isFinal), XML_STATUS_ERROR)
#define EXPAT_NUM_FUNCTIONS (sizeof(expat_names)/sizeof(expat_names[0]))
#define EXPAT_NO_HANDLE ((void*)-1)
#define EXPAT_SO "/usr/lib/libexpat.so.1"
static const char* expat_names[] = {
"XML_ParserCreate",
#define FN_NAME(type,name,params,args,fail) #name,
EXPAT_FUNCTIONS(FN_NAME)
};
static struct {
void* handle;
union {
@ -78,20 +88,10 @@ static struct {
#define FN_POINTER(type,name,params,args,fail) type (* name) params;
EXPAT_FUNCTIONS(FN_POINTER)
} expat;
void* entry[1];
void* entry[EXPAT_NUM_FUNCTIONS];
} fn;
} expat;
static const char* expat_names[] = {
"XML_ParserCreate",
#define FN_NAME(type,name,params,args,fail) #name,
EXPAT_FUNCTIONS(FN_NAME)
};
#define EXPAT_NUM_FUNCTIONS (sizeof(expat_names)/sizeof(expat_names[0]))
#define EXPAT_NO_HANDLE ((void*)-1)
#define EXPAT_SO "/usr/lib/libexpat.so.1"
/* XML_ParserCreate() is the special function where we load the library */
XML_Parser
XML_ParserCreate(

View file

@ -43,6 +43,16 @@
f(const char*, magic_file, \
(magic_t cookie, const char* path), (cookie, path), NULL)
#define MAGIC_NUM_FUNCTIONS (sizeof(magic_names)/sizeof(magic_names[0]))
#define MAGIC_NO_HANDLE ((void*)-1)
#define MAGIC_SO "/usr/lib/libmagic.so.1"
static const char* magic_names[] = {
"magic_open",
#define FN_NAME(type,name,params,args,fail) #name,
MAGIC_FUNCTIONS(FN_NAME)
};
static struct {
void* handle;
union {
@ -51,20 +61,10 @@ static struct {
#define FN_POINTER(type,name,params,args,fail) type (* name) params;
MAGIC_FUNCTIONS(FN_POINTER)
} magic;
void* entry[1];
void* entry[MAGIC_NUM_FUNCTIONS];
} fn;
} magic;
static const char* magic_names[] = {
"magic_open",
#define FN_NAME(type,name,params,args,fail) #name,
MAGIC_FUNCTIONS(FN_NAME)
};
#define MAGIC_NUM_FUNCTIONS (sizeof(magic_names)/sizeof(magic_names[0]))
#define MAGIC_NO_HANDLE ((void*)-1)
#define MAGIC_SO "/usr/lib/libmagic.so.1"
/* magic_open() is the special function where we load the library */
magic_t magic_open(int flags)
{

View file

@ -76,6 +76,16 @@
(struct udev_device* dev), \
(dev))
#define LIBUDEV_NUM_FUNCTIONS (sizeof(libudev_names)/sizeof(libudev_names[0]))
#define LIBUDEV_NO_HANDLE ((void*)-1)
#define LIBUDEV_SO "/usr/lib/libudev.so.1"
static const char* libudev_names[] = {
"udev_new",
#define FN_NAME(ret,name,params,args) #name,
LIBUDEV_FUNCTIONS(FN_NAME)
};
static struct {
void* handle;
union {
@ -84,20 +94,10 @@ static struct {
#define FN_POINTER(ret,name,params,args) ret (* name) params;
LIBUDEV_FUNCTIONS(FN_POINTER)
} udev;
void* entry[1];
void* entry[LIBUDEV_NUM_FUNCTIONS];
} fn;
} libudev;
static const char* libudev_names[] = {
"udev_new",
#define FN_NAME(ret,name,params,args) #name,
LIBUDEV_FUNCTIONS(FN_NAME)
};
#define LIBUDEV_NUM_FUNCTIONS (sizeof(libudev_names)/sizeof(libudev_names[0]))
#define LIBUDEV_NO_HANDLE ((void*)-1)
#define LIBUDEV_SO "/usr/lib/libudev.so.1"
/* udev_new() is the special function where we load the library */
struct udev*
udev_new()