commit 6dcce6cb483d06667c474a07ffdfec22668b10ad
parent 27bfb50c589ec4344dd2f9e34b141f96d55ee24f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 10 Oct 2016 10:53:43 +0200
Fix GCC warnings
Make consistent the coding style
Diffstat:
4 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/src/ssol_estimator.c b/src/ssol_estimator.c
@@ -1,17 +1,17 @@
/* Copyright (C) CNRS 2016
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "ssol.h"
#include "ssol_estimator_c.h"
@@ -24,13 +24,14 @@
#include <math.h>
/*******************************************************************************
-* Helper functions
-******************************************************************************/
+ * Helper functions
+ ******************************************************************************/
static void
estimator_release(ref_T* ref)
{
struct ssol_device* dev;
- struct ssol_estimator* estimator = CONTAINER_OF(ref, struct ssol_estimator, ref);
+ struct ssol_estimator* estimator =
+ CONTAINER_OF(ref, struct ssol_estimator, ref);
ASSERT(ref);
dev = estimator->dev;
ASSERT(dev && dev->allocator);
@@ -39,8 +40,8 @@ estimator_release(ref_T* ref)
}
/*******************************************************************************
-* Exported ssol_estimator functions
-******************************************************************************/
+ * Exported ssol_estimator functions
+ ******************************************************************************/
res_T
ssol_estimator_create
(struct ssol_device* dev,
@@ -48,12 +49,13 @@ ssol_estimator_create
{
struct ssol_estimator* estimator = NULL;
res_T res = RES_OK;
+
if (!dev || !out_estimator) {
- return RES_BAD_ARG;
+ res = RES_BAD_ARG;
+ goto error;
}
- estimator = (struct ssol_estimator*)MEM_CALLOC
- (dev->allocator, 1, sizeof(struct ssol_estimator));
+ estimator = MEM_CALLOC(dev->allocator, 1, sizeof(struct ssol_estimator));
if (!estimator) {
res = RES_MEM_ERR;
goto error;
@@ -66,6 +68,7 @@ ssol_estimator_create
exit:
if (out_estimator) *out_estimator = estimator;
return res;
+
error:
if (estimator) {
SSOL(estimator_ref_put(estimator));
@@ -75,6 +78,23 @@ error:
}
res_T
+ssol_estimator_ref_get
+(struct ssol_estimator* estimator)
+{
+ if (!estimator) return RES_BAD_ARG;
+ ref_get(&estimator->ref);
+ return RES_OK;
+}
+
+res_T
+ssol_estimator_ref_put
+(struct ssol_estimator* estimator)
+{
+ if (!estimator) return RES_BAD_ARG;
+ ref_put(&estimator->ref, estimator_release);
+ return RES_OK;
+}
+res_T
ssol_estimator_get_status
(const struct ssol_estimator* estimator,
enum status_type type,
@@ -85,19 +105,18 @@ ssol_estimator_get_status
return RES_BAD_ARG;
switch (type) {
- case STATUS_SHADOW:
- data = &estimator->shadow;
- break;
- case STATUS_MISSING:
- data = &estimator->missing;
- break;
- default: FATAL("Unreachable code.\n"); break;
+ case STATUS_SHADOW:
+ data = &estimator->shadow;
+ break;
+ case STATUS_MISSING:
+ data = &estimator->missing;
+ break;
+ default: FATAL("Unreachable code.\n"); break;
}
status->N = estimator->realisation_count;
- status->E = data->weight / status->N;
- status->V = data->sqr_weight / status->N - status->E * status->E;
- status->SE = (status->V > 0) ? sqrt(status->V / status->N) : 0;
-
+ status->E = data->weight / (double)status->N;
+ status->V = data->sqr_weight / (double)status->N - status->E * status->E;
+ status->SE = (status->V > 0) ? sqrt(status->V / (double)status->N) : 0;
return RES_OK;
}
@@ -114,22 +133,4 @@ ssol_estimator_clear
return RES_OK;
}
-res_T
-ssol_estimator_ref_get
-(struct ssol_estimator* estimator)
-{
- if (!estimator)
- return RES_BAD_ARG;
- ref_get(&estimator->ref);
- return RES_OK;
-}
-res_T
-ssol_estimator_ref_put
-(struct ssol_estimator* estimator)
-{
- if (!estimator)
- return RES_BAD_ARG;
- ref_put(&estimator->ref, estimator_release);
- return RES_OK;
-}
diff --git a/src/ssol_scene.c b/src/ssol_scene.c
@@ -46,8 +46,8 @@ scene_release(ref_T* ref)
SSOL(scene_clear(scene));
if(scene->scn_rt) S3D(scene_ref_put(scene->scn_rt));
if(scene->scn_samp) S3D(scene_ref_put(scene->scn_samp));
- if (scene->sun) SSOL(sun_ref_put(scene->sun));
- if (scene->atmosphere) SSOL(atmosphere_ref_put(scene->atmosphere));
+ if(scene->sun) SSOL(sun_ref_put(scene->sun));
+ if(scene->atmosphere) SSOL(atmosphere_ref_put(scene->atmosphere));
htable_instance_release(&scene->instances_rt);
htable_instance_release(&scene->instances_samp);
MEM_RM(dev->allocator, scene);
@@ -413,8 +413,8 @@ hit_filter_function
receiver_name = &inst->receiver_back;
}
- /* Check if the hit surface is a receiver that registers hit data */
- /* impacts on receivers before sampled surfaces are not registered */
+ /* Check if the hit surface is a receiver that registers hit data
+ * impacts on receivers before sampled surfaces are not registered */
if (!seg->sun_segment && !str_is_empty(receiver_name)) {
struct receiver_record candidate;
f3_set_d3(candidate.dir, seg->dir);
diff --git a/src/test_ssol_estimator.c b/src/test_ssol_estimator.c
@@ -15,7 +15,6 @@
#include "ssol.h"
#include "test_ssol_utils.h"
-#include "test_ssol_materials.h"
#define HALF_X 1
#define HALF_Y 1
@@ -31,8 +30,8 @@
#include <star/ssp.h>
/*******************************************************************************
-* Test main program
-******************************************************************************/
+ * Test main program
+ ******************************************************************************/
int
main(int argc, char** argv)
{
diff --git a/src/test_ssol_solver3N.c b/src/test_ssol_solver3N.c
@@ -114,8 +114,8 @@ main(int argc, char** argv)
FILE* tmp;
double m, std;
int i, j, k;
- (void) argc, (void) argv;
uint32_t r_id;
+ (void) argc, (void) argv;
mem_init_proxy_allocator(&allocator, &mem_default_allocator);