summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c86
1 files changed, 42 insertions, 44 deletions
diff --git a/src/H5T.c b/src/H5T.c
index cea739e..8f09cbc 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2470,7 +2470,7 @@ done:
htri_t
H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
{
- int i;
+ unsigned i;
htri_t ret_value=FALSE; /* Return value */
FUNC_ENTER_NOAPI(H5T_detect_class, FAIL);
@@ -3530,7 +3530,7 @@ H5T_t *
H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
{
H5T_t *new_dt=NULL, *tmp=NULL;
- int i;
+ unsigned i;
char *s;
H5T_t *ret_value;
@@ -3605,7 +3605,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t));
for (i=0; i<new_dt->u.compnd.nmembs; i++) {
- int j;
+ unsigned j;
int old_match;
s = new_dt->u.compnd.memb[i].name;
@@ -3773,7 +3773,7 @@ done:
herr_t
H5T_free(H5T_t *dt)
{
- int i;
+ unsigned i;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_free, FAIL);
@@ -4099,9 +4099,11 @@ H5T_get_size(const H5T_t *dt)
int
H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
{
- int *idx1 = NULL, *idx2 = NULL;
+ unsigned *idx1 = NULL, *idx2 = NULL;
int ret_value = 0;
- int i, j, tmp;
+ int i, j;
+ unsigned u;
+ int tmp;
hbool_t swapped;
size_t base_size;
@@ -4138,11 +4140,11 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int))))
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(unsigned))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(unsigned))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
- for (i=0; i<dt1->u.compnd.nmembs; i++)
- idx1[i] = idx2[i] = i;
+ for (u=0; u<dt1->u.compnd.nmembs; u++)
+ idx1[u] = idx2[u] = u;
for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
@@ -4168,35 +4170,31 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
#ifdef H5T_DEBUG
/* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt1->u.compnd.memb[idx1[i + 1]].name));
- assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
- dt2->u.compnd.memb[idx2[i + 1]].name));
+ for (u=0; u<dt1->u.compnd.nmembs-1; u++) {
+ assert(HDstrcmp(dt1->u.compnd.memb[idx1[u]].name,
+ dt1->u.compnd.memb[idx1[u + 1]].name));
+ assert(HDstrcmp(dt2->u.compnd.memb[idx2[u]].name,
+ dt2->u.compnd.memb[idx2[u + 1]].name));
}
#endif
/* Compare the members */
- for (i=0; i<dt1->u.compnd.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt2->u.compnd.memb[idx2[i]].name);
+ for (u=0; u<dt1->u.compnd.nmembs; u++) {
+ tmp = HDstrcmp(dt1->u.compnd.memb[idx1[u]].name,
+ dt2->u.compnd.memb[idx2[u]].name);
if (tmp < 0)
HGOTO_DONE(-1);
if (tmp > 0)
HGOTO_DONE(1);
- if (dt1->u.compnd.memb[idx1[i]].offset <
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].offset >
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
+ if (dt1->u.compnd.memb[idx1[u]].offset < dt2->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[u]].offset > dt2->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1);
- if (dt1->u.compnd.memb[idx1[i]].size <
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].size >
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
+ if (dt1->u.compnd.memb[idx1[u]].size < dt2->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[u]].size > dt2->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1);
- tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type,
- dt2->u.compnd.memb[idx2[i]].type);
+ tmp = H5T_cmp(dt1->u.compnd.memb[idx1[u]].type,
+ dt2->u.compnd.memb[idx2[u]].type);
if (tmp < 0) HGOTO_DONE(-1);
if (tmp > 0) HGOTO_DONE(1);
}
@@ -4212,11 +4210,11 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int))))
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(unsigned))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(unsigned))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
- for (i=0; i<dt1->u.enumer.nmembs; i++)
- idx1[i] = idx2[i] = i;
+ for (u=0; u<dt1->u.enumer.nmembs; u++)
+ idx1[u] = idx2[u] = u;
for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (HDstrcmp(dt1->u.enumer.name[idx1[j]],
@@ -4242,24 +4240,24 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
#ifdef H5T_DEBUG
/* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.enumer.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt1->u.enumer.name[idx1[i+1]]));
- assert(HDstrcmp(dt2->u.enumer.name[idx2[i]],
- dt2->u.enumer.name[idx2[i+1]]));
+ for (u=0; u<dt1->u.enumer.nmembs-1; u++) {
+ assert(HDstrcmp(dt1->u.enumer.name[idx1[u]],
+ dt1->u.enumer.name[idx1[u+1]]));
+ assert(HDstrcmp(dt2->u.enumer.name[idx2[u]],
+ dt2->u.enumer.name[idx2[u+1]]));
}
#endif
/* Compare the members */
base_size = dt1->parent->size;
- for (i=0; i<dt1->u.enumer.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt2->u.enumer.name[idx2[i]]);
+ for (u=0; u<dt1->u.enumer.nmembs; u++) {
+ tmp = HDstrcmp(dt1->u.enumer.name[idx1[u]],
+ dt2->u.enumer.name[idx2[u]]);
if (tmp<0) HGOTO_DONE(-1);
if (tmp>0) HGOTO_DONE(1);
- tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size,
- dt2->u.enumer.value+idx2[i]*base_size,
+ tmp = HDmemcmp(dt1->u.enumer.value+idx1[u]*base_size,
+ dt2->u.enumer.value+idx2[u]*base_size,
base_size);
if (tmp<0) HGOTO_DONE(-1);
if (tmp>0) HGOTO_DONE(1);
@@ -5073,7 +5071,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
{
htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */
htri_t ret_value = 0; /* Indicate that success, but no location change */
- int i; /* Local index variable */
+ unsigned i; /* Local index variable */
int accum_change; /* Amount of change in the offset of the fields */
size_t old_size; /* Previous size of a field */
@@ -5271,7 +5269,7 @@ herr_t
H5T_debug(const H5T_t *dt, FILE *stream)
{
const char *s1="", *s2="";
- int i;
+ unsigned i;
size_t k, base_size;
uint64_t tmp;
herr_t ret_value=SUCCEED; /* Return value */