Skip to content

Commit

Permalink
Fix compiler warnings (#9098)
Browse files Browse the repository at this point in the history
* Fix some compiler warnings
  • Loading branch information
AnHeuermann committed Jun 15, 2022
1 parent 3ea5d0b commit c5de1e4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 3 deletions.
Expand Up @@ -1432,7 +1432,7 @@ cast(LDOUBLE value)
* comparison (cf. C99: 6.3.1.4, 2). It might then equal the LDOUBLE
* value although converting the latter to UINTMAX_T would overflow.
*/
if (value >= UINTMAX_MAX)
if (value >= (double)UINTMAX_MAX)
return UINTMAX_MAX;

result = value;
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/SimulationRuntime/c/gc/omc_gc.c
Expand Up @@ -111,6 +111,7 @@ void mmc_do_out_of_memory()
omc_assert_warning(info, "Out of memory! Faking a stack overflow.");
mmc_do_stackoverflow(threadData);
#endif
abort(); // Silence invalid noreturn warning. This is never reached.
}

#if !(defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME))
Expand Down
8 changes: 8 additions & 0 deletions OMCompiler/SimulationRuntime/c/openmodelica_types.h
Expand Up @@ -33,6 +33,8 @@
#ifndef OPENMODELICA_TYPES_H_
#define OPENMODELICA_TYPES_H_

#include <limits.h>

#if defined(__cplusplus)
extern "C" {
#endif
Expand Down Expand Up @@ -63,6 +65,8 @@ typedef modelica_metatype modelica_string;
#define PRINT_MMC_UINT_T "lu"
typedef unsigned long mmc_uint_t;
typedef long mmc_sint_t;
#define MODELICA_INT_MIN LONG_MIN;
#define MODELICA_INT_MAX LONG_MAX;

#elif defined(_LLP64) || defined(_WIN64) || defined(__MINGW64__) /* windows 64bit */

Expand All @@ -79,6 +83,8 @@ typedef long mmc_sint_t;
#define PRINT_MMC_UINT_T PRIu64
typedef unsigned long long mmc_uint_t;
typedef long long mmc_sint_t;
#define MODELICA_INT_MIN LONG_MIN;
#define MODELICA_INT_MAX LONG_MAX;

#else /* 32bit platforms */

Expand All @@ -89,6 +95,8 @@ typedef long long mmc_sint_t;
#define PRINT_MMC_UINT_T "u"
typedef unsigned int mmc_uint_t;
typedef int mmc_sint_t;
#define MODELICA_INT_MIN INT_MIN;
#define MODELICA_INT_MAX INT_MAX;

#endif

Expand Down
Expand Up @@ -210,9 +210,9 @@ modelica_boolean doOverride(omc_ModelInput *mi, MODEL_DATA *modelData, const cha

static const double REAL_MIN = -DBL_MAX;
static const double REAL_MAX = DBL_MAX;
static const double INTEGER_MIN = (((modelica_integer)-1)<<(8*sizeof(modelica_integer)-1));
static const double INTEGER_MIN = (double)MODELICA_INT_MIN;
/* Avoid integer overflow */
static const double INTEGER_MAX = -((((modelica_integer)-1)<<(8*sizeof(modelica_integer)-1))+1);
static const double INTEGER_MAX = (double)MODELICA_INT_MAX;

/* reads double value from a string */
static void read_value_real(const char *s, modelica_real* res, modelica_real default_value);
Expand Down
Expand Up @@ -112,6 +112,7 @@ void omc_assert_simulation(threadData_t *threadData, FILE_INFO info, const char
va_start(args, msg);
va_omc_assert_simulation_withEquationIndexes(threadData, info, NULL, msg, args);
va_end(args);
abort(); // Silence invalid noreturn warning. This is never reached.
}

void omc_assert_simulation_withEquationIndexes(threadData_t *threadData, FILE_INFO info, const int *indexes, const char *msg, ...)
Expand All @@ -120,6 +121,7 @@ void omc_assert_simulation_withEquationIndexes(threadData_t *threadData, FILE_IN
va_start(args, msg);
va_omc_assert_simulation_withEquationIndexes(threadData, info, indexes, msg, args);
va_end(args);
abort(); // Silence invalid noreturn warning. This is never reached.
}


Expand Down
3 changes: 3 additions & 0 deletions OMCompiler/SimulationRuntime/c/util/ModelicaUtilities.c
Expand Up @@ -80,17 +80,20 @@ void (*OpenModelica_ModelicaVFormatError)(const char*,va_list) MODELICA_NORETURN

void ModelicaError(const char* string) {
OpenModelica_ModelicaError(string);
abort(); // Silence invalid noreturn warning. This is never reached.
}

void ModelicaVFormatError(const char*string, va_list args) {
OpenModelica_ModelicaVFormatError(string,args);
abort(); // Silence invalid noreturn warning. This is never reached.
}

void ModelicaFormatError(const char* string, ...) {
va_list args;
va_start(args, string);
OpenModelica_ModelicaVFormatError(string,args);
va_end(args);
abort(); // Silence invalid noreturn warning. This is never reached.
}

char* ModelicaAllocateString(size_t len) {
Expand Down
2 changes: 2 additions & 0 deletions OMNotebook/OMNotebook/OMNotebookGUI/qtapp.cpp
Expand Up @@ -60,7 +60,9 @@
#include <sys/time.h>
#endif

#ifndef GC_THREADS
#define GC_THREADS
#endif

extern "C" {
#include "meta/meta_modelica.h"
Expand Down
2 changes: 2 additions & 0 deletions OMShell/OMShell/OMShellGUI/main.cpp
Expand Up @@ -51,7 +51,9 @@
#include "omcinteractiveenvironment.h"
#include <stdio.h>

#ifndef GC_THREADS
#define GC_THREADS
#endif

extern "C" {
#include "meta/meta_modelica.h"
Expand Down

0 comments on commit c5de1e4

Please sign in to comment.