Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-31 18:45:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-31 19:01:00 +0400
commit70f2389f5a9052efab319d0b21999db7bcfc73b0 (patch)
tree8b9cddee8b3fd2d44abbeb7662979a9db3e7208b /source/blender/blenkernel/intern
parent1af6e656ec60b3dcebe722c9c8cf6b133ec0b411 (diff)
Code cleanup: be less vague checking invalid index values
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/customdata.c42
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c4
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
3 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index fc123d37a7b..5a5b9f1747f 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1793,7 +1793,7 @@ bool CustomData_free_layer_active(CustomData *data, int type, int totelem)
{
int index = 0;
index = CustomData_get_active_layer_index(data, type);
- if (index < 0) return 0;
+ if (index == -1) return 0;
return CustomData_free_layer(data, type, totelem, index);
}
@@ -1838,7 +1838,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int t
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
layer = &data->layers[layer_index];
@@ -1871,7 +1871,7 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
/* get the layer index of the desired layer */
layer_index = CustomData_get_named_layer_index(data, type, name);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
layer = &data->layers[layer_index];
@@ -1903,7 +1903,7 @@ bool CustomData_is_referenced_layer(struct CustomData *data, int type)
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return 0;
+ if (layer_index == -1) return 0;
layer = &data->layers[layer_index];
@@ -2007,7 +2007,7 @@ void CustomData_copy_data_named(const CustomData *source, CustomData *dest,
dest_i = CustomData_get_named_layer_index(dest, source->layers[src_i].type, source->layers[src_i].name);
/* if we found a matching layer, copy the data */
- if (dest_i > -1) {
+ if (dest_i != -1) {
CustomData_copy_data_layer(source, dest, src_i, dest_i, source_index, dest_index, count);
}
}
@@ -2148,7 +2148,7 @@ void *CustomData_get(const CustomData *data, int index, int type)
/* get the layer index of the active layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
/* get the offset of the desired element */
offset = layerType_getInfo(type)->size * index;
@@ -2165,7 +2165,7 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
/* get the layer index of the first layer of type */
layer_index = data->typemap[type];
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
offset = layerType_getInfo(type)->size * index;
return (char *)data->layers[layer_index + n].data + offset;
@@ -2175,7 +2175,7 @@ void *CustomData_get_layer(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
return data->layers[layer_index].data;
}
@@ -2184,7 +2184,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
return data->layers[layer_index].data;
}
@@ -2193,7 +2193,7 @@ void *CustomData_get_layer_named(const struct CustomData *data, int type,
const char *name)
{
int layer_index = CustomData_get_named_layer_index(data, type, name);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
return data->layers[layer_index].data;
}
@@ -2202,7 +2202,7 @@ int CustomData_get_offset(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return -1;
+ if (layer_index == -1) return -1;
return data->layers[layer_index].offset;
}
@@ -2211,7 +2211,7 @@ int CustomData_get_n_offset(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index < 0) return -1;
+ if (layer_index == -1) return -1;
return data->layers[layer_index].offset;
}
@@ -2221,7 +2221,7 @@ bool CustomData_set_layer_name(const CustomData *data, int type, int n, const ch
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index < 0) return false;
+ if (layer_index == -1) return false;
if (!name) return false;
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
@@ -2234,7 +2234,7 @@ void *CustomData_set_layer(const CustomData *data, int type, void *ptr)
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
data->layers[layer_index].data = ptr;
@@ -2245,7 +2245,7 @@ void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, voi
{
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
data->layers[layer_index].data = ptr;
@@ -2614,7 +2614,7 @@ void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
return (char *)block + data->layers[layer_index].offset;
}
@@ -2625,7 +2625,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
/* get the layer index of the first layer of type */
layer_index = CustomData_get_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ if (layer_index == -1) return NULL;
return (char *)block + data->layers[layer_index + n].offset;
}
@@ -3070,7 +3070,7 @@ void CustomData_validate_layer_name(const CustomData *data, int type, const char
if (name[0])
index = CustomData_get_named_layer_index(data, type, name);
- if (index < 0) {
+ if (index == -1) {
/* either no layer was specified, or the layer we want has been
* deleted, so assign the active layer to name
*/
@@ -3319,7 +3319,7 @@ void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNU
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return;
+ if (layer_index == -1) return;
layer = &data->layers[layer_index];
@@ -3343,7 +3343,7 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
int layer_index; // i, remove_file;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return;
+ if (layer_index == -1) return;
layer = &data->layers[layer_index];
@@ -3377,7 +3377,7 @@ bool CustomData_external_test(CustomData *data, int type)
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return false;
+ if (layer_index == -1) return false;
layer = &data->layers[layer_index];
return (layer->flag & CD_FLAG_EXTERNAL) != 0;
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 3436728254b..325a26d7a16 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -1165,7 +1165,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
}
/* Remove and free the given F-Modifier from the given stack */
-int remove_fmodifier(ListBase *modifiers, FModifier *fcm)
+bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
{
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
@@ -1252,7 +1252,7 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
* - mtype - type of modifier (if 0, doesn't matter)
* - acttype - type of action to perform (if -1, doesn't matter)
*/
-short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
+bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
{
FModifier *fcm;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index ab314d8b148..fbca675e5ee 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -769,7 +769,7 @@ MovieTrackingTrack *BKE_tracking_track_get_active(MovieTracking *tracking)
tracksbase = BKE_tracking_get_active_tracks(tracking);
/* check that active track is in current tracks list */
- if (BLI_findindex(tracksbase, tracking->act_track) >= 0)
+ if (BLI_findindex(tracksbase, tracking->act_track) != -1)
return tracking->act_track;
return NULL;
@@ -1284,7 +1284,7 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_get_active(struct MovieTrackin
plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
/* Check that active track is in current plane tracks list */
- if (BLI_findindex(plane_tracks_base, tracking->act_plane_track) >= 0) {
+ if (BLI_findindex(plane_tracks_base, tracking->act_plane_track) != -1) {
return tracking->act_plane_track;
}