star-phor-input

File format for describing photoreactor configurations
git clone https://www.edstar.cnrs.fr/git/star-phor-input.git
Log | Files | Refs | README | LICENSE

commit 86bd7c698a0127dfc4b851c0ff4ba4a6d1080844
parent 1e2d352630d1f0e2dfebfbbdbedff17f914f66d9
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date:   Mon, 12 May 2025 17:26:30 +0200

Improve code style consistency

This commit makes several small changes throughout the codebase:
 - Removes trailing whitespace at the end of lines
 - Removes unused #define directives
 - Ensures consistent function definitions: arguments must start on a new
   line, even if there is only one
 - Fix unused variable warning during compilation

Diffstat:
Mdoc/star-phor-input.scd | 2+-
Msphin.pc.in | 4++--
Msrc/sphin.h | 3++-
Msrc/sphin_brdf.c | 9++++++---
Msrc/sphin_config.c | 9++++++---
Msrc/sphin_geometry.c | 14++++++++------
Msrc/sphin_main.c | 14++++++++------
Msrc/sphin_sensor.c | 9++++++---
Msrc/sphin_source.c | 14++++++++++----
Msrc/sphin_surface.c | 9++++++---
Msrc/sphin_volume.c | 9++++++---
Msrc/test_sphin.c | 4++--
Msrc/test_sphin_load_geometry.c | 1-
Msrc/test_sphin_load_source.c | 3+--
Msrc/test_sphin_load_surface.c | 1-
Msrc/test_sphin_load_volume.c | 1-
16 files changed, 64 insertions(+), 42 deletions(-)

diff --git a/doc/star-phor-input.scd b/doc/star-phor-input.scd @@ -93,7 +93,7 @@ The file format describing a photoreactive system is as follows: <side> ::= 'FRONT' | 'BACK' <geom-file> ::= path % STL files only % Spaces not allowed -<geom-unit> ::= 'm' % if no unit is specified, +<geom-unit> ::= 'm' % if no unit is specified, | 'cm' % meter is assumed | 'mm' | 'km' diff --git a/sphin.pc.in b/sphin.pc.in @@ -2,9 +2,9 @@ prefix=@PREFIX@ includedir=${prefix}/include libdir=${prefix}/lib -Requires: rsys >= @RSYS_VERSION@ +Requires: rsys >= @RSYS_VERSION@ Requires.private: sstl >= @SSTL_VERSION@ -Name: Star-Phor Input +Name: Star-Phor Input Description: File reader for the Star-Phor solver Version: @VERSION@ Libs: -L${libdir} -lsphin diff --git a/src/sphin.h b/src/sphin.h @@ -69,6 +69,7 @@ enum sphin_source_direction_distribution_type { SPHIN_SOURCE_DIRECTION_ISOTROPIC, SPHIN_SOURCE_DIRECTION_NONE__ }; + struct sphin_create_args { struct logger* logger; /* May be NULL <=> default logger */ struct mem_allocator* allocator; /* NULL <=> use default allocator */ @@ -191,8 +192,8 @@ static const struct sphin_geometry_descriptor * Users must interact with these structures exclusively through the * functions provided by the library (e.g., those prefixed with sphin_get).*/ struct sphin; /* Library handler */ -struct sphin_brdf; struct sphin_config; /* Physical configuration */ +struct sphin_brdf; struct sphin_geometry; struct sphin_sensor; struct sphin_source; diff --git a/src/sphin_brdf.c b/src/sphin_brdf.c @@ -74,7 +74,8 @@ error: } static void -release_brdf(ref_T* address) +release_brdf + (ref_T* address) { struct sphin_brdf* brdf = NULL; struct sphin* sphin = NULL; @@ -157,7 +158,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_brdf_ref_get(struct sphin_brdf* brdf) +sphin_brdf_ref_get + (struct sphin_brdf* brdf) { if (NULL == brdf) { return RES_BAD_ARG; @@ -167,7 +169,8 @@ sphin_brdf_ref_get(struct sphin_brdf* brdf) } res_T -sphin_brdf_ref_put(struct sphin_brdf* brdf) +sphin_brdf_ref_put + (struct sphin_brdf* brdf) { if (NULL == brdf) { return RES_BAD_ARG; diff --git a/src/sphin_config.c b/src/sphin_config.c @@ -75,7 +75,8 @@ error: } static void -release_config(ref_T* address) +release_config + (ref_T* address) { struct sphin_config* config = NULL; struct sphin* sphin = NULL; @@ -328,7 +329,8 @@ sphin_load_stream } res_T -sphin_config_ref_get(struct sphin_config* config) +sphin_config_ref_get + (struct sphin_config* config) { if (NULL == config) { return RES_BAD_ARG; @@ -338,7 +340,8 @@ sphin_config_ref_get(struct sphin_config* config) } res_T -sphin_config_ref_put(struct sphin_config* config) +sphin_config_ref_put + (struct sphin_config* config) { if (NULL == config) { return RES_BAD_ARG; diff --git a/src/sphin_geometry.c b/src/sphin_geometry.c @@ -27,14 +27,15 @@ #include "sphin_geometry.h" #include <rsys/cstr.h> +#include <rsys/double3.h> #include <star/sstl.h> /******************************************************************************* * Helper functions ******************************************************************************/ - static void -release_geometry(ref_T* address) +release_geometry + (ref_T* address) { struct sphin_geometry* geometry = NULL; struct sphin* sphin = NULL; @@ -67,7 +68,6 @@ geometry_create geom = MEM_CALLOC(sphin->allocator, 1, sizeof(struct sphin_geometry)); if (NULL == geom) { res = RES_MEM_ERR; goto error; } - /* Init geometry ref counter and init member variables */ ref_init(&geom->ref); SPHIN(ref_get(sphin)); @@ -138,7 +138,7 @@ geometry_parse /* Parse unit and evaluate scaling factor*/ unit = strtok_r(NULL, " \t", &token_ptr); if (NULL == unit - || 0 == strcmp(unit, "m")){scaling_factor = 1e+00;} + || 0 == strcmp(unit, "m")){scaling_factor = 1e+00;} else if (0 == strcmp(unit, "cm")){scaling_factor = 1e-02;} else if (0 == strcmp(unit, "mm")){scaling_factor = 1e-03;} else if (0 == strcmp(unit, "km")){scaling_factor = 1e+03;} @@ -187,7 +187,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_geometry_ref_get(struct sphin_geometry* geometry) +sphin_geometry_ref_get + (struct sphin_geometry* geometry) { if (NULL == geometry) { return RES_BAD_ARG; @@ -197,7 +198,8 @@ sphin_geometry_ref_get(struct sphin_geometry* geometry) } res_T -sphin_geometry_ref_put(struct sphin_geometry* geometry) +sphin_geometry_ref_put + (struct sphin_geometry* geometry) { if (NULL == geometry) { return RES_BAD_ARG; diff --git a/src/sphin_main.c b/src/sphin_main.c @@ -44,14 +44,16 @@ struct args { static const struct args ARGS_DEFAULT = ARGS_DEFAULT__; static void -usage(FILE* stream) +usage + (FILE* stream) { ASSERT(NULL != stream); fprintf(stream, "Usage: sphin [-hv] [file]\n"); } static res_T -parse_args(struct args* args, int argc, char** argv) +parse_args + (struct args* args, int argc, char** argv) { int opt = 0; res_T res = RES_OK; @@ -65,10 +67,10 @@ parse_args(struct args* args, int argc, char** argv) while((opt = getopt(argc, argv, "hv")) != -1) { switch(opt) { case 'v': - /* Increase the verbosity level counter for each 'v' entered, up to a maximum of 3. - * We use the boolean value of (3 > args->verbose): if the condition is - * true, it evaluates to 1, increasing the counter. - * Otherwise, it evaluates to 0, leaving the counter unchanged. */ + /* Increase the verbosity level counter for each 'v' entered, up to a + * maximum of 3. We use the boolean value of (3 > args->verbose): if + * the condition is true, it evaluates to 1, increasing the counter. + * Otherwise, it evaluates to 0, leaving the counter unchanged. */ args->verbose += (3 > args->verbose); break; case 'h': diff --git a/src/sphin_sensor.c b/src/sphin_sensor.c @@ -81,7 +81,8 @@ error: } static void -release_sensor(ref_T* address) +release_sensor + (ref_T* address) { struct sphin_sensor* sensor = NULL; struct sphin* sphin = NULL; @@ -199,7 +200,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_sensor_ref_get(struct sphin_sensor* sensor) +sphin_sensor_ref_get + (struct sphin_sensor* sensor) { if (NULL == sensor) { return RES_BAD_ARG; @@ -209,7 +211,8 @@ sphin_sensor_ref_get(struct sphin_sensor* sensor) } res_T -sphin_sensor_ref_put(struct sphin_sensor* sensor) +sphin_sensor_ref_put + (struct sphin_sensor* sensor) { if (NULL == sensor) { return RES_BAD_ARG; diff --git a/src/sphin_source.c b/src/sphin_source.c @@ -43,7 +43,6 @@ struct sphin_source { ref_T ref; }; - /******************************************************************************* * Helper functions ******************************************************************************/ @@ -85,7 +84,8 @@ error: } static void -release_source(ref_T* address) +release_source + (ref_T* address) { struct sphin_source* source = NULL; struct sphin* sphin = NULL; @@ -130,6 +130,8 @@ parse_collim_direction_distribution double direction[3]; res_T res = RES_OK; + (void)txtrdr; + ASSERT(NULL != dir_dist); ASSERT(NULL != txtrdr); @@ -165,6 +167,8 @@ parse_cos_pow_n_direction_distribution double collimation_degree; res_T res = RES_OK; + (void)txtrdr; + ASSERT(NULL != dir_dist); ASSERT(NULL != txtrdr); @@ -376,7 +380,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_source_ref_get(struct sphin_source* source) +sphin_source_ref_get + (struct sphin_source* source) { if (NULL == source) { return RES_BAD_ARG; @@ -386,7 +391,8 @@ sphin_source_ref_get(struct sphin_source* source) } res_T -sphin_source_ref_put(struct sphin_source* source) +sphin_source_ref_put + (struct sphin_source* source) { if (NULL == source) { return RES_BAD_ARG; diff --git a/src/sphin_surface.c b/src/sphin_surface.c @@ -93,7 +93,8 @@ error: } static void -release_surface(ref_T* address) +release_surface + (ref_T* address) { size_t i, ngeometries; struct sphin* sphin = NULL; @@ -255,7 +256,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_surface_ref_get(struct sphin_surface* surface) +sphin_surface_ref_get + (struct sphin_surface* surface) { if (NULL == surface) { return RES_BAD_ARG; @@ -265,7 +267,8 @@ sphin_surface_ref_get(struct sphin_surface* surface) } res_T -sphin_surface_ref_put(struct sphin_surface* surface) +sphin_surface_ref_put + (struct sphin_surface* surface) { if (NULL == surface) { return RES_BAD_ARG; diff --git a/src/sphin_volume.c b/src/sphin_volume.c @@ -88,7 +88,8 @@ error: } static void -release_volume(ref_T* address) +release_volume + (ref_T* address) { size_t i, ngeometries; struct sphin_geometry** geometries = NULL; @@ -285,7 +286,8 @@ error: * Exported functions ******************************************************************************/ res_T -sphin_volume_ref_get(struct sphin_volume* volume) +sphin_volume_ref_get + (struct sphin_volume* volume) { if (NULL == volume) { return RES_BAD_ARG; @@ -295,7 +297,8 @@ sphin_volume_ref_get(struct sphin_volume* volume) } res_T -sphin_volume_ref_put(struct sphin_volume* volume) +sphin_volume_ref_put + (struct sphin_volume* volume) { if (NULL == volume) { return RES_BAD_ARG; diff --git a/src/test_sphin.c b/src/test_sphin.c @@ -55,7 +55,7 @@ main(int argc, char** argv) CHK(sphin_ref_get(sphin) == RES_OK); CHK(sphin_ref_put(NULL) == RES_BAD_ARG); CHK(sphin_ref_put(sphin) == RES_OK); - /* Call ref_put twice to ensure release sphin is called */ + /* Call ref_put twice to ensure release sphin is called */ CHK(sphin_ref_put(sphin) == RES_OK); /* At this point, the memory for the sphin instance has been released. It is * no longer valid to interact with the sphin object or to use any functions @@ -95,6 +95,6 @@ main(int argc, char** argv) check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); CHK(mem_allocated_size() == 0); - + return 0; } diff --git a/src/test_sphin_load_geometry.c b/src/test_sphin_load_geometry.c @@ -23,7 +23,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sphin.h" -#include "test_sphin_utils.h" #include <rsys/math.h> #include <rsys/mem_allocator.h> diff --git a/src/test_sphin_load_source.c b/src/test_sphin_load_source.c @@ -23,7 +23,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sphin.h" -#include "test_sphin_utils.h" #include <rsys/math.h> #include <rsys/mem_allocator.h> @@ -107,7 +106,7 @@ test_source_api CHK(sphin_source_ref_put(NULL) == RES_BAD_ARG); CHK(sphin_source_ref_get(source) == RES_OK); CHK(sphin_source_ref_put(source) == RES_OK); - + CHK(sphin_config_get_surface(config, 1, &surface) == RES_OK); CHK(sphin_surface_get_source(surface, &source) == RES_OK); CHK(sphin_source_get_direction_distribution(source, &dir_dist) == RES_OK); diff --git a/src/test_sphin_load_surface.c b/src/test_sphin_load_surface.c @@ -23,7 +23,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sphin.h" -#include "test_sphin_utils.h" #include <rsys/math.h> #include <rsys/mem_allocator.h> diff --git a/src/test_sphin_load_volume.c b/src/test_sphin_load_volume.c @@ -23,7 +23,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sphin.h" -#include "test_sphin_utils.h" #include <rsys/math.h> #include <rsys/mem_allocator.h>