diff --git a/example_apps/matrix_factorization/als_vertices_inmem.cpp b/example_apps/matrix_factorization/als_vertices_inmem.cpp index d59a01a1..9e5b58df 100644 --- a/example_apps/matrix_factorization/als_vertices_inmem.cpp +++ b/example_apps/matrix_factorization/als_vertices_inmem.cpp @@ -22,7 +22,7 @@ * * @section DESCRIPTION * - * Matrix factorizatino with the Alternative Least Squares (ALS) algorithm. + * Matrix factorization with the Alternative Least Squares (ALS) algorithm. * This code is based on GraphLab's implementation of ALS by Joey Gonzalez * and Danny Bickson (CMU). A good explanation of the algorithm is * given in the following paper: @@ -102,7 +102,7 @@ struct ALSVerticesInMemProgram : public GraphChiProgram &vertex, graphchi_context &gcontext) { - if (gcontext.iteration == 0) { + if (gcontext.iteration == 0) { /* On first iteration, initialize vertex (and its edges). This is usually required, because on each run, GraphChi will modify the data files. To start from scratch, it is easiest do initialize the program in code. Alternatively, you can keep a copy of initial data files. */ diff --git a/example_apps/randomwalks.cpp b/example_apps/randomwalks.cpp index eb6b7f48..39506809 100644 --- a/example_apps/randomwalks.cpp +++ b/example_apps/randomwalks.cpp @@ -174,5 +174,5 @@ int main(int argc, const char ** argv) { /* Report execution metrics */ metrics_report(m); - return 0; + return 0; } diff --git a/src/preprocessing/conversions.hpp b/src/preprocessing/conversions.hpp index 3d174e9d..4ab8edb0 100644 --- a/src/preprocessing/conversions.hpp +++ b/src/preprocessing/conversions.hpp @@ -339,7 +339,7 @@ namespace graphchi { // Read next line linenum += num + 1; for(vid_t i=0; i < num; i++) { - fgets(s, maxlen, inf); + s = fgets(s, maxlen, inf); FIXLINE(s); vid_t to = atoi(s); if (from != to) { @@ -386,9 +386,10 @@ namespace graphchi { vid_t from; vid_t to; - fread(&from, 1, sizeof(vid_t), inf); - fread(&to, 1, sizeof(vid_t), inf); + int res1 = fread(&from, sizeof(vid_t), 1, inf); + int res2 = fread(&to, sizeof(vid_t), 1, inf); + assert(res1 > 0 && res2 > 0); if (from != to) { sharderobj.preprocessing_add_edge(from, to, EdgeDataType()); } @@ -427,9 +428,10 @@ namespace graphchi { vid_t to; EdgeDataType edgeval; - fread(&from, 1, sizeof(vid_t), inf); - fread(&to, 1, sizeof(vid_t), inf); - fread(&edgeval, 1, sizeof(EdgeDataType), inf); + int res1 = fread(&from, sizeof(vid_t), 1, inf); + int res2 = fread(&to, sizeof(vid_t), 1, inf); + int res3 = fread(&edgeval, sizeof(EdgeDataType), 1, inf); + assert(res1 > 0 && res2 > 0 && res3 > 0); if (from != to) { sharderobj.preprocessing_add_edge(from, to, edgeval); } diff --git a/src/preprocessing/formats/binary_adjacency_list.hpp b/src/preprocessing/formats/binary_adjacency_list.hpp index cff37d0c..882f9f7e 100644 --- a/src/preprocessing/formats/binary_adjacency_list.hpp +++ b/src/preprocessing/formats/binary_adjacency_list.hpp @@ -196,7 +196,12 @@ namespace graphchi { logstream(LOG_FATAL) << "Could not open file " << filename << " for writing. " << " Error: " << strerror(errno) << std::endl; } - ftruncate(fd, 0); + int res = ftruncate(fd, 0); + if (res != 0) { + logstream(LOG_FATAL) << "Could not truncate file " << filename << + " Error: " << strerror(errno) << std::endl; + } + assert(res == 0); header.format_version = FORMAT_VERSION; header.max_vertex_id = 0;