Make introspection compile with -Wall -Werror

Address all gcc warnings, -Werror is not enabled yet but at least
-Wall -Werror passes on my machine.
This commit is contained in:
Johan Dahlin 2012-04-09 14:19:23 -03:00 committed by Johan Dahlin
parent d0b8813d14
commit 0a96da9284
14 changed files with 91 additions and 9 deletions

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
#define UNASSIGNED 3U
@ -508,6 +509,10 @@ int bdz_dump(cmph_t *mphf, FILE *fd)
nbytes = fwrite(&(data->ranktablesize), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(data->ranktable, sizeof(cmph_uint32)*(data->ranktablesize), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
#ifdef DEBUG
cmph_uint32 i;
fprintf(stderr, "G: ");
@ -549,6 +554,10 @@ void bdz_load(FILE *f, cmph_t *mphf)
bdz->ranktable = (cmph_uint32 *)calloc((size_t)bdz->ranktablesize, sizeof(cmph_uint32));
nbytes = fread(bdz->ranktable, sizeof(cmph_uint32)*(bdz->ranktablesize), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return;
}
#ifdef DEBUG
cmph_uint32 i = 0;

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
#define UNASSIGNED 3
@ -465,6 +466,10 @@ int bdz_ph_dump(cmph_t *mphf, FILE *fd)
sizeg = (cmph_uint32)ceil(data->n/5.0);
nbytes = fwrite(data->g, sizeof(cmph_uint8)*sizeg, (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
#ifdef DEBUG
cmph_uint32 i;
fprintf(stderr, "G: ");
@ -501,6 +506,9 @@ void bdz_ph_load(FILE *f, cmph_t *mphf)
bdz_ph->g = (cmph_uint8 *)calloc((size_t)sizeg, sizeof(cmph_uint8));
nbytes = fread(bdz_ph->g, sizeg*sizeof(cmph_uint8), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
return;
}

View File

@ -11,6 +11,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
@ -469,6 +470,10 @@ int bmz_dump(cmph_t *mphf, FILE *fd)
nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(data->g, sizeof(cmph_uint32)*(data->n), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
#ifdef DEBUG
cmph_uint32 i;
fprintf(stderr, "G: ");
@ -510,6 +515,10 @@ void bmz_load(FILE *f, cmph_t *mphf)
bmz->g = (cmph_uint32 *)malloc(sizeof(cmph_uint32)*bmz->n);
nbytes = fread(bmz->g, bmz->n*sizeof(cmph_uint32), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return;
}
#ifdef DEBUG
fprintf(stderr, "G: ");
for (i = 0; i < bmz->n; ++i) fprintf(stderr, "%u ", bmz->g[i]);

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
@ -482,6 +483,10 @@ int bmz8_dump(cmph_t *mphf, FILE *fd)
nbytes = fwrite(&(data->m), sizeof(cmph_uint8), (size_t)1, fd);
nbytes = fwrite(data->g, sizeof(cmph_uint8)*(data->n), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
/* #ifdef DEBUG
fprintf(stderr, "G: ");
for (i = 0; i < data->n; ++i) fprintf(stderr, "%u ", data->g[i]);
@ -523,6 +528,10 @@ void bmz8_load(FILE *f, cmph_t *mphf)
bmz8->g = (cmph_uint8 *)malloc(sizeof(cmph_uint8)*bmz8->n);
nbytes = fread(bmz8->g, bmz8->n*sizeof(cmph_uint8), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return;
}
#ifdef DEBUG
fprintf(stderr, "G: ");
for (i = 0; i < bmz8->n; ++i) fprintf(stderr, "%u ", bmz8->g[i]);

View File

@ -15,6 +15,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#define MAX_BUCKET_SIZE 255
//#define DEBUG
#include "debug.h"
@ -370,7 +371,11 @@ static int brz_gen_mphf(cmph_config_t *mph)
nbytes = fwrite(&(brz->algo), sizeof(brz->algo), (size_t)1, brz->mphf_fd);
nbytes = fwrite(&(brz->k), sizeof(cmph_uint32), (size_t)1, brz->mphf_fd); // number of MPHFs
nbytes = fwrite(brz->size, sizeof(cmph_uint8)*(brz->k), (size_t)1, brz->mphf_fd);
if (nbytes == 0 && ferror(brz->mphf_fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
//tmp_fds = (FILE **)calloc(nflushes, sizeof(FILE *));
buff_manager = buffer_manager_new(brz->memory_availability, nflushes);
buffer_merge = (cmph_uint8 **)calloc((size_t)nflushes, sizeof(cmph_uint8 *));
@ -574,6 +579,10 @@ int brz_dump(cmph_t *mphf, FILE *fd)
// Dumping m and the vector offset.
nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(data->offset, sizeof(cmph_uint32)*(data->k), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
return 1;
}
@ -639,6 +648,9 @@ void brz_load(FILE *f, cmph_t *mphf)
nbytes = fread(&(brz->m), sizeof(cmph_uint32), (size_t)1, f);
brz->offset = (cmph_uint32 *)malloc(sizeof(cmph_uint32)*brz->k);
nbytes = fread(brz->offset, sizeof(cmph_uint32)*(brz->k), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
return;
}

View File

@ -5,6 +5,7 @@
#include<time.h>
#include<assert.h>
#include<limits.h>
#include<errno.h>
#include "cmph_structs.h"
#include "chd_structs.h"
@ -189,6 +190,9 @@ void chd_load(FILE *fd, cmph_t *mphf)
DEBUGP("Loading Compressed rank structure, which has %u bytes\n", chd->packed_cr_size);
chd->packed_cr = (cmph_uint8 *) calloc((size_t)chd->packed_cr_size, (size_t)1);
nbytes = fread(chd->packed_cr, chd->packed_cr_size, (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
}
int chd_dump(cmph_t *mphf, FILE *fd)
@ -206,7 +210,10 @@ int chd_dump(cmph_t *mphf, FILE *fd)
DEBUGP("Dumping compressed rank structure with %u bytes to disk\n", buflen);
nbytes = fwrite(&data->packed_cr_size, sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(data->packed_cr, data->packed_cr_size, (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
return 1;
}

View File

@ -5,6 +5,7 @@
#include<time.h>
#include<assert.h>
#include<limits.h>
#include<errno.h>
#include "cmph_structs.h"
#include "chd_structs_ph.h"
@ -859,6 +860,9 @@ void chd_ph_load(FILE *fd, cmph_t *mphf)
DEBUGP("Reading n and nbuckets\n");
nbytes = fread(&(chd_ph->n), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fread(&(chd_ph->nbuckets), sizeof(cmph_uint32), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
}
int chd_ph_dump(cmph_t *mphf, FILE *fd)
@ -885,6 +889,10 @@ int chd_ph_dump(cmph_t *mphf, FILE *fd)
// dumping n and nbuckets
nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(&(data->nbuckets), sizeof(cmph_uint32), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
return 1;
}

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
@ -225,6 +226,10 @@ int chm_dump(cmph_t *mphf, FILE *fd)
nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(data->g, sizeof(cmph_uint32)*data->n, (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
/* #ifdef DEBUG
fprintf(stderr, "G: ");
for (i = 0; i < data->n; ++i) fprintf(stderr, "%u ", data->g[i]);
@ -265,6 +270,10 @@ void chm_load(FILE *f, cmph_t *mphf)
chm->g = (cmph_uint32 *)malloc(sizeof(cmph_uint32)*chm->n);
nbytes = fread(chm->g, chm->n*sizeof(cmph_uint32), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return;
}
#ifdef DEBUG
fprintf(stderr, "G: ");
for (i = 0; i < chm->n; ++i) fprintf(stderr, "%u ", chm->g[i]);

View File

@ -151,12 +151,11 @@ static void key_vector_rewind(void *data)
static cmph_uint32 count_nlfile_keys(FILE *fd)
{
cmph_uint32 count = 0;
register char * ptr;
rewind(fd);
while(1)
{
char buf[BUFSIZ];
ptr = fgets(buf, BUFSIZ, fd);
fgets(buf, BUFSIZ, fd);
if (feof(fd)) break;
if (buf[strlen(buf) - 1] != '\n') continue;
++count;

View File

@ -1,6 +1,7 @@
#include "cmph_structs.h"
#include <string.h>
#include <errno.h>
//#define DEBUG
#include "debug.h"
@ -27,6 +28,9 @@ void __cmph_dump(cmph_t *mphf, FILE *fd)
register size_t nbytes;
nbytes = fwrite(cmph_names[mphf->algo], (size_t)(strlen(cmph_names[mphf->algo]) + 1), (size_t)1, fd);
nbytes = fwrite(&(mphf->size), sizeof(mphf->size), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
}
cmph_t *__cmph_load(FILE *f)
{
@ -62,6 +66,9 @@ cmph_t *__cmph_load(FILE *f)
nbytes = fread(&(mphf->size), sizeof(mphf->size), (size_t)1, f);
mphf->data = NULL;
DEBUGP("Algorithm is %s and mphf is sized %u\n", cmph_names[algo], mphf->size);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
return mphf;
}

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#define INDEX 0 /* alignment index within a bucket */
//#define DEBUG
#include "debug.h"
@ -339,6 +340,10 @@ int fch_dump(cmph_t *mphf, FILE *fd)
nbytes = fwrite(&(data->p1), sizeof(double), (size_t)1, fd);
nbytes = fwrite(&(data->p2), sizeof(double), (size_t)1, fd);
nbytes = fwrite(data->g, sizeof(cmph_uint32)*(data->b), (size_t)1, fd);
if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}
#ifdef DEBUG
cmph_uint32 i;
fprintf(stderr, "G: ");
@ -387,6 +392,10 @@ void fch_load(FILE *f, cmph_t *mphf)
fch->g = (cmph_uint32 *)malloc(sizeof(cmph_uint32)*fch->b);
nbytes = fread(fch->g, fch->b*sizeof(cmph_uint32), (size_t)1, f);
if (nbytes == 0 && ferror(f)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return;
}
#ifdef DEBUG
cmph_uint32 i;
fprintf(stderr, "G: ");

View File

@ -172,7 +172,7 @@ g_value_from_ffi_value (GValue *gvalue,
g_value_set_string (gvalue, (gchar*)value->v_pointer);
break;
case G_TYPE_CHAR:
g_value_set_char (gvalue, (gchar)value->v_long);
g_value_set_schar (gvalue, (gchar)value->v_long);
break;
case G_TYPE_UCHAR:
g_value_set_uchar (gvalue, (guchar)value->v_ulong);

View File

@ -372,7 +372,6 @@ register_internal (GIRepository *repository,
{
Header *header;
const gchar *namespace;
const gchar *version;
g_return_val_if_fail (typelib != NULL, FALSE);
@ -381,7 +380,6 @@ register_internal (GIRepository *repository,
g_return_val_if_fail (header != NULL, FALSE);
namespace = g_typelib_get_string (typelib, header->namespace);
version = g_typelib_get_string (typelib, header->nsversion);
if (lazy)
{

View File

@ -771,11 +771,9 @@ write_constant_info (const gchar *namespace,
{
GITypeInfo *type;
const gchar *name;
gboolean deprecated;
GIArgument value;
name = g_base_info_get_name ((GIBaseInfo *)info);
deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info);
xml_start_element (file, "constant");
xml_printf (file, " name=\"%s\"", name);