summaryrefslogtreecommitdiffstats
path: root/perform
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2011-09-06 14:16:50 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2011-09-06 14:16:50 (GMT)
commitb3bc8132c5661f9e2b5f0222bef8791d9193b25c (patch)
treee23bed5598353d5a6486746cfd4e87e6462f2084 /perform
parent12e6abe9f448866f008c6381a805cc4198748ef2 (diff)
downloadhdf5-b3bc8132c5661f9e2b5f0222bef8791d9193b25c.zip
hdf5-b3bc8132c5661f9e2b5f0222bef8791d9193b25c.tar.gz
hdf5-b3bc8132c5661f9e2b5f0222bef8791d9193b25c.tar.bz2
[svn-r21363] files from HDF5-33 review - all changes ran correctly in trunk. Changes have been tested in cmake branch.
Tested: local linux
Diffstat (limited to 'perform')
-rw-r--r--perform/pio_engine.c102
-rw-r--r--perform/zip_perf.c2
2 files changed, 55 insertions, 49 deletions
diff --git a/perform/pio_engine.c b/perform/pio_engine.c
index 27606d0..511492b 100644
--- a/perform/pio_engine.c
+++ b/perform/pio_engine.c
@@ -22,7 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
+#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include "hdf5.h"
@@ -411,14 +413,14 @@ done:
static char *
pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size)
{
- const char *prefix, *suffix="";
+ const char *prefix, *suffix = "";
char *ptr, last = '\0';
size_t i, j;
if (!base_name || !fullname || size < 1)
- return NULL;
+ return NULL;
- memset(fullname, 0, size);
+ HDmemset(fullname, 0, size);
switch (iot) {
case POSIXIO:
@@ -433,77 +435,81 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
}
/* First use the environment variable and then try the constant */
- prefix = getenv("HDF5_PARAPREFIX");
+ prefix = HDgetenv("HDF5_PARAPREFIX");
#ifdef HDF5_PARAPREFIX
if (!prefix)
- prefix = HDF5_PARAPREFIX;
+ prefix = HDF5_PARAPREFIX;
#endif /* HDF5_PARAPREFIX */
/* Prepend the prefix value to the base name */
if (prefix && *prefix) {
- /* If the prefix specifies the HDF5_PARAPREFIX directory, then
- * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
- * directory instead. */
- register char *user, *login, *subdir;
-
- user = getenv("USER");
- login = getenv("LOGIN");
- subdir = (user ? user : login);
+ /* If the prefix specifies the HDF5_PARAPREFIX directory, then
+ * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
+ * directory instead. */
+ register char *user, *login, *subdir;
- if (subdir) {
- for (i = 0; i < size && prefix[i]; i++)
- fullname[i] = prefix[i];
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
+ subdir = (user ? user : login);
- fullname[i++] = '/';
+ if (subdir) {
+ for (i = 0; i < size && prefix[i]; i++)
+ fullname[i] = prefix[i];
- for (j = 0; i < size && subdir[j]; i++, j++)
- fullname[i] = subdir[j];
- } else {
- /* We didn't append the prefix yet */
- strncpy(fullname, prefix, MIN(strlen(prefix), size));
- }
+ fullname[i++] = '/';
- if ((strlen(fullname) + strlen(base_name) + 1) < size) {
- /* Append the base_name with a slash first. Multiple slashes are
- * handled below. */
- h5_stat_t buf;
-
- if (HDstat(fullname, &buf) < 0)
- /* The directory doesn't exist just yet */
- if (mkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) {
- /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
- * Default to PREFIX's original prefix value. */
- strcpy(fullname, prefix);
+ for (j = 0; i < size && subdir[j]; i++, j++)
+ fullname[i] = subdir[j];
+ }
+ else {
+ /* We didn't append the prefix yet */
+ HDstrncpy(fullname, prefix, MIN(HDstrlen(prefix), size));
}
- strcat(fullname, "/");
- strcat(fullname, base_name);
- } else {
+ if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) {
+ /* Append the base_name with a slash first. Multiple slashes are
+ * handled below. */
+ h5_stat_t buf;
+
+ if (HDstat(fullname, &buf) < 0)
+ /* The directory doesn't exist just yet */
+ if (HDmkdir(fullname, (mode_t) 0755) < 0 && errno != EEXIST) {
+ /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
+ * Default to PREFIX's original prefix value. */
+ HDstrcpy(fullname, prefix);
+ }
+
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
+ }
+ else {
+ /* Buffer is too small */
+ return NULL;
+ }
+ }
+ else if (HDstrlen(base_name) >= size) {
/* Buffer is too small */
return NULL;
}
- } else if (strlen(base_name) >= size) {
- /* Buffer is too small */
- return NULL;
- } else {
- strcpy(fullname, base_name);
+ else {
+ HDstrcpy(fullname, base_name);
}
/* Append a suffix */
if (suffix) {
- if (strlen(fullname) + strlen(suffix) >= size)
- return NULL;
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
+ return NULL;
- strcat(fullname, suffix);
+ HDstrcat(fullname, suffix);
}
/* Remove any double slashes in the filename */
for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
- if (*ptr != '/' || last != '/')
- fullname[j++] = *ptr;
+ if (*ptr != '/' || last != '/')
+ fullname[j++] = *ptr;
- last = *ptr;
+ last = *ptr;
}
return fullname;
diff --git a/perform/zip_perf.c b/perform/zip_perf.c
index fdd824b..897fc7e 100644
--- a/perform/zip_perf.c
+++ b/perform/zip_perf.c
@@ -413,7 +413,7 @@ fill_with_random_data(Bytef *src, uLongf src_len)
register unsigned u;
h5_stat_t stat_buf;
- if (stat("/dev/urandom", &stat_buf) == 0) {
+ if (HDstat("/dev/urandom", &stat_buf) == 0) {
uLongf len = src_len;
Bytef *buf = src;
int fd = HDopen("/dev/urandom", O_RDONLY, 0);