Commit 6579566c by Celine Mercier

Minor changes in code to improve readability and fix C compilation

warnings
parent 410e2e02
......@@ -32,7 +32,7 @@ cdef class OBIDMS_column:
cdef OBIDMS_column_p pointer
cdef OBIDMS dms
cdef str data_type # TODO keep as OBIType_t? both?
cdef str data_type
cdef str dms_name
cdef str column_name
cdef index_t nb_elements_per_line
......
......@@ -61,7 +61,8 @@ cdef class OBIDMS :
# Fill structure and create or open the DMS
self.dms_name = dms_name
self.pointer = obi_dms(<const_char_p> dms_name_b)
# TODO: test pointer and raise Exception("Failed opening or creating an OBIDMS")
if self.pointer == NULL :
raise Exception("Failed opening or creating an OBIDMS")
cpdef close(self) :
......
......@@ -16,13 +16,8 @@ cdef extern from "obidmscolumn.h" nogil:
cdef extern from "obitypes.h" nogil:
enum OBIType: # TODO je sais pas si ça sert de declarer le contenu de l'enum
OBI_VOID = 0,
OBI_INT,
OBI_FLOAT,
OBI_BOOL,
OBI_CHAR,
OBI_IDX
enum OBIType:
pass
ctypedef OBIType OBIType_t
......
......@@ -182,7 +182,7 @@ int array_compare(byte_t* value_1, byte_t* value_2);
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
size_t array_sizeof(byte_t* value); // TODO not sure about type
size_t array_sizeof(byte_t* value);
/************************************************************************
......@@ -311,7 +311,7 @@ int grow_array(OBIDMS_array_p array) // TODO Lock when needed
header_size = (array->header)->header_size;
file_size = header_size + new_data_size;
// Enlarge the file // TODO isn't it possible that this makes the file "move"?
// Enlarge the file
if (ftruncate(array_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_ARRAY_ERROR);
......@@ -392,7 +392,7 @@ int grow_array_data(OBIDMS_array_p array) // TODO Lock when needed
header_size = ((array->data)->header)->header_size;
file_size = header_size + new_data_size;
// Enlarge the file // TODO isn't it possible that this makes the file "move"?
// Enlarge the file
if (ftruncate(array_data_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_ARRAY_ERROR);
......@@ -788,7 +788,7 @@ OBIDMS_array_p obi_open_array(OBIDMS_p dms, const char* array_name)
}
// Read the header size
if (read(array_data_file_descriptor, &header_size, sizeof(size_t)) < sizeof(size_t))
if (read(array_data_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBI_ARRAY_ERROR);
obidebug(1, "\nError reading the header size to open a data array");
......@@ -867,7 +867,7 @@ OBIDMS_array_p obi_open_array(OBIDMS_p dms, const char* array_name)
}
// Read the header size
if (read(array_file_descriptor, &header_size, sizeof(size_t)) < sizeof(size_t))
if (read(array_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBI_ARRAY_ERROR);
obidebug(1, "\nError reading the header size to open an array");
......@@ -982,7 +982,7 @@ index_t obi_array_add(OBIDMS_array_p array, byte_t* value)
// Grow the data if needed
value_size = array_sizeof(value);
while (*data_size_max_p < (data_size_used + value_size)) // TODO problem with types
while (*data_size_max_p < (data_size_used + (int64_t) value_size))
{
if (grow_array_data(array) < 0)
return -1;
......
......@@ -252,7 +252,7 @@ static obiversion_t obi_get_new_version_number(OBIDMS_column_directory_p column_
}
// Read the current version number
if (read(version_file_descriptor, &new_version_number, sizeof(obiversion_t)) < sizeof(obiversion_t))
if (read(version_file_descriptor, &new_version_number, sizeof(obiversion_t)) < ((ssize_t) sizeof(obiversion_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError reading a version file");
......@@ -263,7 +263,7 @@ static obiversion_t obi_get_new_version_number(OBIDMS_column_directory_p column_
new_version_number++;
// Write the new version number
if (write(version_file_descriptor, &new_version_number, sizeof(obiversion_t)) < sizeof(obiversion_t))
if (write(version_file_descriptor, &new_version_number, sizeof(obiversion_t)) < ((ssize_t) sizeof(obiversion_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError writing a new version number in a version file");
......@@ -349,7 +349,7 @@ static obiversion_t create_version_file(OBIDMS_column_directory_p column_directo
}
// Write version number
if (write(version_file_descriptor, &version_number, sizeof(obiversion_t)) < sizeof(obiversion_t))
if (write(version_file_descriptor, &version_number, sizeof(obiversion_t)) < ((ssize_t) sizeof(obiversion_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError writing version number in a version file");
......@@ -444,7 +444,7 @@ obiversion_t obi_get_latest_version_number(OBIDMS_column_directory_p column_dire
}
// Read the latest version number
if (read(version_file_descriptor, &latest_version_number, sizeof(obiversion_t)) < sizeof(obiversion_t))
if (read(version_file_descriptor, &latest_version_number, sizeof(obiversion_t)) < ((ssize_t) sizeof(obiversion_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError reading the latest version number in a version file");
......@@ -788,7 +788,7 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
}
// Read the header size
if (read(column_file_descriptor, &header_size, sizeof(size_t)) < sizeof(size_t))
if (read(column_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError reading the header size to open a column");
......@@ -1044,7 +1044,6 @@ int obi_enlarge_column(OBIDMS_column_p column)
index_t new_line_count;
int column_file_descriptor;
char* column_file_name;
void* new_data;
// Get the column file name
column_file_name = build_column_file_name((column->header)->name, (column->header)->version);
......@@ -1232,7 +1231,7 @@ OBIDMS_column_header_p obi_column_get_header_from_name(OBIDMS_p dms, const char*
free(column_file_name);
// Read the header size
if (read(column_file_descriptor, &header_size, sizeof(size_t)) < sizeof(size_t))
if (read(column_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError reading the header size to read a header");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment