From 0a96da92840cf0eb043b6ddb8c2618a23f8cbabe Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 9 Apr 2012 14:19:23 -0300 Subject: [PATCH] Make introspection compile with -Wall -Werror Address all gcc warnings, -Werror is not enabled yet but at least -Wall -Werror passes on my machine. --- cmph/bdz.c | 9 +++++++++ cmph/bdz_ph.c | 8 ++++++++ cmph/bmz.c | 9 +++++++++ cmph/bmz8.c | 9 +++++++++ cmph/brz.c | 14 +++++++++++++- cmph/chd.c | 9 ++++++++- cmph/chd_ph.c | 8 ++++++++ cmph/chm.c | 9 +++++++++ cmph/cmph.c | 3 +-- cmph/cmph_structs.c | 7 +++++++ cmph/fch.c | 9 +++++++++ ginvoke.c | 2 +- girepository.c | 2 -- girwriter.c | 2 -- 14 files changed, 91 insertions(+), 9 deletions(-) diff --git a/cmph/bdz.c b/cmph/bdz.c index a57f70f84..a385b152a 100755 --- a/cmph/bdz.c +++ b/cmph/bdz.c @@ -9,6 +9,7 @@ #include #include #include +#include //#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; diff --git a/cmph/bdz_ph.c b/cmph/bdz_ph.c index 16257c0f4..2e9860712 100755 --- a/cmph/bdz_ph.c +++ b/cmph/bdz_ph.c @@ -9,6 +9,7 @@ #include #include #include +#include //#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; } diff --git a/cmph/bmz.c b/cmph/bmz.c index 3eabfb7f2..9c6cea004 100644 --- a/cmph/bmz.c +++ b/cmph/bmz.c @@ -11,6 +11,7 @@ #include #include #include +#include //#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]); diff --git a/cmph/bmz8.c b/cmph/bmz8.c index 4db4dfce8..206c48c4d 100644 --- a/cmph/bmz8.c +++ b/cmph/bmz8.c @@ -10,6 +10,7 @@ #include #include #include +#include //#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]); diff --git a/cmph/brz.c b/cmph/brz.c index f9c48ef7c..f0c91c4bd 100755 --- a/cmph/brz.c +++ b/cmph/brz.c @@ -15,6 +15,7 @@ #include #include #include +#include #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; } diff --git a/cmph/chd.c b/cmph/chd.c index 7fb3b8bb8..71579ee34 100644 --- a/cmph/chd.c +++ b/cmph/chd.c @@ -5,6 +5,7 @@ #include #include #include +#include #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; } diff --git a/cmph/chd_ph.c b/cmph/chd_ph.c index 71f83fbd3..6cd9437a9 100644 --- a/cmph/chd_ph.c +++ b/cmph/chd_ph.c @@ -5,6 +5,7 @@ #include #include #include +#include #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; } diff --git a/cmph/chm.c b/cmph/chm.c index 9cdbf41bc..3af8c8069 100644 --- a/cmph/chm.c +++ b/cmph/chm.c @@ -10,6 +10,7 @@ #include #include #include +#include //#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]); diff --git a/cmph/cmph.c b/cmph/cmph.c index cba735f4f..0c4b67d12 100644 --- a/cmph/cmph.c +++ b/cmph/cmph.c @@ -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; diff --git a/cmph/cmph_structs.c b/cmph/cmph_structs.c index b5634248f..9ecf5fc0e 100644 --- a/cmph/cmph_structs.c +++ b/cmph/cmph_structs.c @@ -1,6 +1,7 @@ #include "cmph_structs.h" #include +#include //#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; } diff --git a/cmph/fch.c b/cmph/fch.c index 67b68fbbe..f6e16e346 100644 --- a/cmph/fch.c +++ b/cmph/fch.c @@ -9,6 +9,7 @@ #include #include #include +#include #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: "); diff --git a/ginvoke.c b/ginvoke.c index 6c39c48ec..ed4996d9f 100644 --- a/ginvoke.c +++ b/ginvoke.c @@ -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); diff --git a/girepository.c b/girepository.c index bcc4a1b42..b5c30297a 100644 --- a/girepository.c +++ b/girepository.c @@ -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) { diff --git a/girwriter.c b/girwriter.c index 73088a12f..5b39e2def 100644 --- a/girwriter.c +++ b/girwriter.c @@ -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);