commit 3d7ff7fdf160d33adbab7eba68dccd3d94292e36
parent 2bf32c5581db695785b1accbb7bd9962bba431f6
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 1 May 2020 19:22:51 +0200
Fix warnings
Diffstat:
5 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/green-compute.c b/src/green-compute.c
@@ -13,6 +13,7 @@
* 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 "green-compute.h"
#include "green-types.h"
#include <rsys/str.h>
@@ -21,6 +22,8 @@
#include <rsys/text_reader.h>
#include <math.h>
+#include <string.h>
+#include <ctype.h>
void
check_green_table_variables_use
@@ -40,8 +43,7 @@ check_green_table_variables_use
FOR_EACH(i, 0, green->counts.ok_count) {
const struct sample* sample = green->samples + i;
unsigned id = sample->header.end_id;
- enum description_type type = green->descriptions[id].type;
- ASSERT(!DESC_IS_H(type));
+ ASSERT(!DESC_IS_H(green->descriptions[id].type));
ASSERT(id <= green->counts.desc_count); /* Ambient ID is desc_count */
green->table[id].end_references_count++;
@@ -49,16 +51,14 @@ check_green_table_variables_use
const double w = sample->pw_weights[j];
id = sample->pw_ids[j];
ASSERT(id < green->counts.desc_count);
- type = green->descriptions[id].type;
- ASSERT(DESC_IS_MEDIUM(type));
+ ASSERT(DESC_IS_MEDIUM(green->descriptions[id].type));
green->table[id].other_references_weight += w;
}
FOR_EACH(j, 0, sample->header.fx_count) {
const double w = sample->fx_weights[j];
id = sample->fx_ids[j];
ASSERT(id < green->counts.desc_count);
- type = green->descriptions[id].type;
- ASSERT(DESC_IS_F(type));
+ ASSERT(DESC_IS_F(type = green->descriptions[id].type));
green->table[id].other_references_weight += w;
}
}
@@ -76,7 +76,7 @@ check_green_table_variables_use
#define MK_VAR(Str) \
for(;;) { \
- int n = snprintf(buf, bufsz, (Str), str_cget(name));\
+ size_t n = (size_t)snprintf(buf, bufsz, (Str), str_cget(name));\
if(n < bufsz) break; \
buf = MEM_REALLOC(green->allocator, buf, n + 1); \
bufsz = n + 1; \
diff --git a/src/green-main.c b/src/green-main.c
@@ -31,8 +31,7 @@ main
{
int err = EXIT_SUCCESS;
res_T res = RES_OK;
- int logger_initialized = 0, allocator_initialized = 0,
- green_initialized = 0;
+ int logger_initialized = 0, green_initialized = 0;
struct mem_allocator allocator;
struct logger logger;
struct green green;
@@ -40,7 +39,6 @@ main
FILE* stream = NULL;
ERR(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- allocator_initialized = 1;
ERR(logger_init(&allocator, &logger));
logger_initialized = 1;
@@ -102,6 +100,7 @@ main
exit:
if(green_initialized) green_release(&green);
+ if(logger_initialized) logger_release(&logger);
if(stream) fclose(stream);
return err;
error:
diff --git a/src/green-output.c b/src/green-output.c
@@ -17,6 +17,7 @@
#include <rsys/str.h>
#include <rsys/mem_allocator.h>
+#include "green-output.h"
#include "green-types.h"
#include "green-version.h"
@@ -138,11 +139,13 @@ dump_green_info
FOR_EACH(i, 0, green->counts.desc_count + 1) {
struct table_elt* elt = green->table + i;
if(elt->end_defined && elt->end_references_count) {
- if(!fst) fprintf(stream, ", "); fst = 0;
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
fprintf(stream, "%s", str_cget(&elt->end_name));
}
if(elt->other_defined && elt->other_references_weight) {
- if(!fst) fprintf(stream, ", "); fst = 0;
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
fprintf(stream, "%s", str_cget(&elt->other_name));
}
}
@@ -160,11 +163,13 @@ dump_green_info
FOR_EACH(i, 0, green->counts.desc_count + 1) {
struct table_elt* elt = green->table + i;
if(elt->end_defined && !elt->end_references_count) {
- if(!fst) fprintf(stream, ", "); fst = 0;
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
fprintf(stream, "%s", str_cget(&elt->end_name));
}
if(elt->other_defined && !elt->other_references_weight) {
- if(!fst) fprintf(stream, ", "); fst = 0;
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
fprintf(stream, "%s", str_cget(&elt->other_name));
}
}
diff --git a/src/green-output.h b/src/green-output.h
@@ -20,6 +20,8 @@
#include <stdio.h>
+struct green;
+
void
print_version
(FILE* stream);
diff --git a/src/green-types.h b/src/green-types.h
@@ -130,7 +130,7 @@ struct sample {
double* fx_weights;
};
-static res_T
+static INLINE res_T
alloc_sample_buffers
(struct mem_allocator* alloc,
struct sample* sample)