commit 70bb72288ba6d6d31e8229807c09e6c3592b1b27
parent 254245548bf10afa57c81074d5de8586f0c755de
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Thu, 31 Jul 2025 19:34:21 +0200
Fix typos and improve code style consistency
As a consequence, the brilliant "yoda for" was replaced by the standard
FOR_EACH
Diffstat:
5 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/Makefile b/Makefile
@@ -103,7 +103,7 @@ $(DEP_TOOL):
@$(CC) $(CFLAGS_TOOL) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
$(OBJ_TOOL):
- $(CC) $(CFLAG_TOOL) -c $(@:.o=.c) -o $@
+ $(CC) $(CFLAGS_TOOL) -c $(@:.o=.c) -o $@
clean_tool:
rm -f $(DEP_TOOL) $(OBJ_TOOL) sphin
@@ -160,7 +160,7 @@ uninstall:
clean: clean_test clean_tool
rm -f $(DEP) $(OBJ) $(LIBNAME)
- rm -f .config sphin-local.pc sphin.pc
+ rm -f .config sphin-local.pc sphin.pc star-phor-input.5 sphin.1
################################################################################
# Tests
diff --git a/src/sphin.h b/src/sphin.h
@@ -158,7 +158,6 @@ struct sphin_mesh {
size_t vertex_count;
};
#define SPHIN_MESH_NULL__ {NULL, NULL, 0, 0}
-
static const struct sphin_mesh SPHIN_MESH_NULL = SPHIN_MESH_NULL__;
struct sphin_geometry_descriptor {
@@ -203,7 +202,7 @@ struct sphin_volume;
BEGIN_DECLS
/*******************************************************************************
- * API of the sphin handle
+ * API of the sphin handler
******************************************************************************/
SPHIN_API res_T
sphin_create
diff --git a/src/sphin_config.c b/src/sphin_config.c
@@ -92,8 +92,8 @@ release_config
volumes = darray_sphin_volume_ptr_data_get(&config->volumes);
/* Put references for each one of the volumes */
- for (i=nvolumes; i; i--) {
- SPHIN(volume_ref_put(volumes[i-1]));
+ FOR_EACH(i, 0, nvolumes) {
+ SPHIN(volume_ref_put(volumes[i]));
};
darray_sphin_volume_ptr_release(&config->volumes);
@@ -103,8 +103,8 @@ release_config
surfaces = darray_sphin_surface_ptr_data_get(&config->surfaces);
/* Put references for each one of the surfaces */
- for (i=nsurfaces; i; i--) {
- SPHIN(surface_ref_put(surfaces[i-1]));
+ FOR_EACH(i, 0, nsurfaces) {
+ SPHIN(surface_ref_put(surfaces[i]));
};
darray_sphin_surface_ptr_release(&config->surfaces);
@@ -140,18 +140,14 @@ load_stream
str_init(sphin->allocator, &line);
res = config_create(sphin, &config);
- if (RES_OK != res) {
- goto error;
- }
+ if (RES_OK != res) { goto error; }
res = txtrdr_stream(sphin->allocator, stream, streamname, '#', &txtrdr);
- if (RES_OK != res) {
- goto error;
- }
+ if (RES_OK != res) { goto error; }
+
res = txtrdr_read_line(txtrdr);
- if (RES_OK != res) {
- goto error;
- }
+ if (RES_OK != res) { goto error; }
+
while (NULL != txtrdr_get_line(txtrdr)) {
res = str_set(&line, txtrdr_get_cline(txtrdr));
if (RES_OK != res) { goto error; }
@@ -377,7 +373,7 @@ sphin_config_get_volume
}
nvolumes = darray_sphin_volume_ptr_size_get(&config->volumes);
- if (RES_OK != res || ivolume > nvolumes) {
+ if (ivolume > nvolumes) {
return RES_BAD_ARG;
}
@@ -412,7 +408,7 @@ sphin_config_get_surface
}
nsurfaces = darray_sphin_surface_ptr_size_get(&config->surfaces);
- if (RES_OK != res || isurface > nsurfaces) {
+ if (isurface > nsurfaces) {
return RES_BAD_ARG;
}
diff --git a/src/sphin_surface.c b/src/sphin_surface.c
@@ -114,8 +114,8 @@ release_surface
geometries = darray_sphin_geometry_ptr_data_get(&surface->geometries);
/* Put references for each one of the geometries */
- for (i=ngeometries; i; i--) {
- SPHIN(geometry_ref_put(geometries[i-1]));
+ FOR_EACH(i, 0, ngeometries) {
+ SPHIN(geometry_ref_put(geometries[i]));
};
if (NULL != geometries) {
diff --git a/src/sphin_volume.c b/src/sphin_volume.c
@@ -107,8 +107,8 @@ release_volume
geometries = darray_sphin_geometry_ptr_data_get(&volume->geometries);
/* Put references for each one of the geometries */
- for (i=ngeometries; i; i--) {
- SPHIN(geometry_ref_put(geometries[i-1]));
+ FOR_EACH(i, 0, ngeometries) {
+ SPHIN(geometry_ref_put(geometries[i]));
}
if (NULL != geometries) {
darray_sphin_geometry_ptr_release(&volume->geometries);
@@ -194,7 +194,8 @@ parse_ka
}
else { res = RES_BAD_ARG; goto error; }
- /* Assert that there isnt anything but the ka value and its unit in the line */
+ /* Assert that there isnt anything but the ka
+ * value and its unit in the line */
token = strtok_r(NULL, " \t", &token_ptr);
if (NULL != token) { res = RES_BAD_ARG; goto error; }
@@ -326,7 +327,7 @@ sphin_volume_get_sensor
struct sphin_sensor_volume** sensor_volume)
{
if (NULL == volume
- || NULL == sensor_volume ) {
+ || NULL == sensor_volume) {
return RES_BAD_ARG;
}
*sensor_volume = volume->sensor_volume;