summaryrefslogtreecommitdiff
path: root/girepository/cmph
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2012-04-09 14:19:23 -0300
committerJohan Dahlin <jdahlin@litl.com>2012-04-09 14:19:23 -0300
commit7c4fbbd681e89775dbec67f3002f820feb42300b (patch)
treea99dc723141fd872f84c488665e973b483ba0a1e /girepository/cmph
parent47d4e9509a8ffde1cab4a6f8d2be4ce232ba1cfb (diff)
downloadgobject-introspection-7c4fbbd681e89775dbec67f3002f820feb42300b.tar.gz
Make introspection compile with -Wall -Werror
Address all gcc warnings, -Werror is not enabled yet but at least -Wall -Werror passes on my machine.
Diffstat (limited to 'girepository/cmph')
-rwxr-xr-xgirepository/cmph/bdz.c9
-rwxr-xr-xgirepository/cmph/bdz_ph.c8
-rw-r--r--girepository/cmph/bmz.c9
-rw-r--r--girepository/cmph/bmz8.c9
-rwxr-xr-xgirepository/cmph/brz.c14
-rw-r--r--girepository/cmph/chd.c9
-rw-r--r--girepository/cmph/chd_ph.c8
-rw-r--r--girepository/cmph/chm.c9
-rw-r--r--girepository/cmph/cmph.c3
-rw-r--r--girepository/cmph/cmph_structs.c7
-rw-r--r--girepository/cmph/fch.c9
11 files changed, 90 insertions, 4 deletions
diff --git a/girepository/cmph/bdz.c b/girepository/cmph/bdz.c
index a57f70f8..a385b152 100755
--- a/girepository/cmph/bdz.c
+++ b/girepository/cmph/bdz.c
@@ -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;
diff --git a/girepository/cmph/bdz_ph.c b/girepository/cmph/bdz_ph.c
index 16257c0f..2e986071 100755
--- a/girepository/cmph/bdz_ph.c
+++ b/girepository/cmph/bdz_ph.c
@@ -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;
}
diff --git a/girepository/cmph/bmz.c b/girepository/cmph/bmz.c
index 3eabfb7f..9c6cea00 100644
--- a/girepository/cmph/bmz.c
+++ b/girepository/cmph/bmz.c
@@ -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]);
diff --git a/girepository/cmph/bmz8.c b/girepository/cmph/bmz8.c
index 4db4dfce..206c48c4 100644
--- a/girepository/cmph/bmz8.c
+++ b/girepository/cmph/bmz8.c
@@ -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]);
diff --git a/girepository/cmph/brz.c b/girepository/cmph/brz.c
index f9c48ef7..f0c91c4b 100755
--- a/girepository/cmph/brz.c
+++ b/girepository/cmph/brz.c
@@ -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;
}
diff --git a/girepository/cmph/chd.c b/girepository/cmph/chd.c
index 7fb3b8bb..71579ee3 100644
--- a/girepository/cmph/chd.c
+++ b/girepository/cmph/chd.c
@@ -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;
}
diff --git a/girepository/cmph/chd_ph.c b/girepository/cmph/chd_ph.c
index 71f83fbd..6cd9437a 100644
--- a/girepository/cmph/chd_ph.c
+++ b/girepository/cmph/chd_ph.c
@@ -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;
}
diff --git a/girepository/cmph/chm.c b/girepository/cmph/chm.c
index 9cdbf41b..3af8c806 100644
--- a/girepository/cmph/chm.c
+++ b/girepository/cmph/chm.c
@@ -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]);
diff --git a/girepository/cmph/cmph.c b/girepository/cmph/cmph.c
index cba735f4..0c4b67d1 100644
--- a/girepository/cmph/cmph.c
+++ b/girepository/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/girepository/cmph/cmph_structs.c b/girepository/cmph/cmph_structs.c
index b5634248..9ecf5fc0 100644
--- a/girepository/cmph/cmph_structs.c
+++ b/girepository/cmph/cmph_structs.c
@@ -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;
}
diff --git a/girepository/cmph/fch.c b/girepository/cmph/fch.c
index 67b68fbb..f6e16e34 100644
--- a/girepository/cmph/fch.c
+++ b/girepository/cmph/fch.c
@@ -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: ");