aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-01-29 17:15:06 +0100
committerThomas White <taw@physics.org>2019-01-29 17:21:06 +0100
commit1fdbafbb687c32dc167a572a3048e32099720fde (patch)
tree7c2f71637cad9d11fce81cff35e94b24c0b2654c /libcrystfel
parent83b4dbe4a0146da76fbb69fde213176d44e1a2ae (diff)
Fix some compiler warnings about string handling
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/events.c15
-rw-r--r--libcrystfel/src/hdf5-file.c14
2 files changed, 14 insertions, 15 deletions
diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c
index c73a816c..bb4047c9 100644
--- a/libcrystfel/src/events.c
+++ b/libcrystfel/src/events.c
@@ -314,9 +314,9 @@ char *get_event_string(struct event *ev)
}
ret_string=new_ret_string;
- strncpy(&ret_string[ret_string_len],"/", 1);
- strncpy(&ret_string[ret_string_len+1],ev->path_entries[pi],
- strlen(ev->path_entries[pi]));
+ ret_string[ret_string_len] = '/';
+ strcpy(&ret_string[ret_string_len+1],
+ ev->path_entries[pi]);
ret_string_len += 1+strlen(ev->path_entries[pi]);
@@ -330,7 +330,7 @@ char *get_event_string(struct event *ev)
ret_string = new_ret_string;
- strncpy(&ret_string[ret_string_len], "/", 1);
+ ret_string[ret_string_len] = '/';
ret_string_len += 1;
} else {
@@ -357,9 +357,8 @@ char *get_event_string(struct event *ev)
ret_string = new_ret_string;
- strncpy(&ret_string[ret_string_len],"/", 1);
- strncpy(&ret_string[ret_string_len+1], num_buf,
- strlen(num_buf));
+ ret_string[ret_string_len] = '/';
+ strcpy(&ret_string[ret_string_len+1], num_buf);
ret_string_len += 1+strlen(num_buf);
}
@@ -374,7 +373,7 @@ char *get_event_string(struct event *ev)
ret_string = new_ret_string;
- strncpy(&ret_string[ret_string_len], "/", 1);
+ ret_string[ret_string_len] = '/';
ret_string_len += 1;
}
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 6ede34bc..3d9ea0b2 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -2300,11 +2300,11 @@ char **hdfile_read_group(struct hdfile *f, int *n, const char *parent,
H5Lget_name_by_idx(gh, ".", H5_INDEX_NAME, H5_ITER_NATIVE,
i, buf, 255, H5P_DEFAULT);
- res[i] = malloc(256);
+ res[i] = malloc(512);
if ( strlen(parent) > 1 ) {
- snprintf(res[i], 255, "%s/%s", parent, buf);
+ snprintf(res[i], 511, "%s/%s", parent, buf);
} else {
- snprintf(res[i], 255, "%s%s", parent, buf);
+ snprintf(res[i], 511, "%s%s", parent, buf);
} /* ick */
is_image[i] = 0;
@@ -2389,8 +2389,8 @@ int check_path_existence(hid_t fh, const char *path)
char *start = path_copy;
char *sep = NULL;
- strncpy(buffer, "\0",1);
- strncpy(buffer_full_path, "\0", 1);
+ buffer[0] = '\0';
+ buffer_full_path[0] = '\0';
if ( strcmp(path_copy, "/" ) == 0 ) {
return 1;
@@ -2416,7 +2416,7 @@ int check_path_existence(hid_t fh, const char *path)
}
strncpy(buffer, start, sep-start);
- buffer[sep-start]='\0';
+ buffer[sep-start] = '\0';
strcat(buffer_full_path, buffer);
check = H5Lexists(fh, buffer_full_path, H5P_DEFAULT);
@@ -2440,7 +2440,7 @@ int check_path_existence(hid_t fh, const char *path)
} else {
- strncpy(buffer, start, strlen(start)+1);
+ strcpy(buffer, start);
strcat(buffer_full_path, buffer);
check = H5Lexists(fh, buffer_full_path, H5P_DEFAULT);