Skip to content

Commit

Permalink
Some -Werror fixes (including missing headers, making sure noreturn f…
Browse files Browse the repository at this point in the history
…unctions never return)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19854 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 31, 2014
1 parent 6fba80d commit a424099
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 19 deletions.
6 changes: 5 additions & 1 deletion SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -28,11 +28,15 @@
*
*/

#if defined(__CLANG__) || defined(__GNUC__)
#define _GNU_SOURCE /* asprintf */
#endif

#include "openmodelica.h"
#include "meta_modelica.h"
#include "meta_modelica_builtin.h"
#include <limits.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>

Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/c/optimization/constraints/evalfG.c
Expand Up @@ -54,7 +54,7 @@ static inline int evalG22(Number *g, IPOPT_DATA_ *iData, double *x0, int i);
static inline int evalG23(Number *g, IPOPT_DATA_ *iData, double *x0, int i);
static int diff_symColoredODE(double *v, double t, IPOPT_DATA_ *iData, double **J);
static int num_diff_symColoredODE(double *v, double t, IPOPT_DATA_ *iData, double **J);
static int printMaxError(IPOPT_DATA_ *iData, double *g,double time, double * max_err , double * tt, int *xi);
static void printMaxError(IPOPT_DATA_ *iData, double *g,double time, double * max_err , double * tt, int *xi);

/*!
* eval s.t.
Expand Down Expand Up @@ -338,7 +338,7 @@ static inline int evalG23(Number *g, IPOPT_DATA_ *iData, double *x0, int i)

}

static int printMaxError(IPOPT_DATA_ *iData, double *g,double t, double * max_err, double * tt, int *xi)
static void printMaxError(IPOPT_DATA_ *iData, double *g,double t, double * max_err, double * tt, int *xi)
{
double tmp;
int j;
Expand Down
Expand Up @@ -43,6 +43,9 @@
#ifdef WITH_IPOPT

#include "../localFunction.h"
#include "../../simulation/solver/external_input.h"

int allocateIpoptData(IPOPT_DATA_ *iData);

static int set_local_jac_struct(IPOPT_DATA_ *iData, int *nng);
static int local_jac_struct(IPOPT_DATA_ *iData, int *nng);
Expand Down Expand Up @@ -585,7 +588,7 @@ static int optimizer_print_step(IPOPT_DATA_ *iData)
if(j < iData->dim.nx)
fprintf(iData->pFile[j], "%s_%i,", iData->data->modelData.realVarsData[j].info.name, k);
else if(j < iData->dim.nv)
fprintf(iData->pFile[j], "%s_%i,", "u", iData->input_name[j-iData->dim.nx]);
fprintf(iData->pFile[j], "%s_%s,", "u", iData->input_name[j-iData->dim.nx]);
}
return 0;
}
Expand Down
Expand Up @@ -42,6 +42,8 @@
#include "../simulation/solver/dassl.h"
#include "../../simulation/options.h"
#include "../../simulation/results/simulation_result.h"
#include "simulation/solver/external_input.h"
#include "simulation/solver/model_help.h"

#ifdef WITH_IPOPT

Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/simulation/simulation_info_xml.c
Expand Up @@ -199,7 +199,7 @@ static void XMLCALL endElement(void *userData, const char *name)
if(0 == strcmp("equation", name))
{
int i;
xml->equationInfo[curIndex].vars = (VAR_INFO*) malloc(sizeof(VAR_INFO)*xml->equationInfo[curIndex].numVar);
xml->equationInfo[curIndex].vars = (VAR_INFO**) malloc(sizeof(VAR_INFO)*xml->equationInfo[curIndex].numVar);
for(i=0; i<xml->equationInfo[curIndex].numVar; i++)
{
VAR_INFO *var = (VAR_INFO*) malloc(sizeof(VAR_INFO));
Expand Down
8 changes: 5 additions & 3 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -914,6 +914,9 @@ int _main_SimulationRuntime(int argc, char**argv, DATA *data)
return retVal;
}

static void omc_assert_simulation(threadData_t *threadData, FILE_INFO info, const char *msg, ...) __attribute__ ((noreturn));
static void omc_throw_simulation(threadData_t* threadData) __attribute__ ((noreturn));

static void omc_assert_simulation(threadData_t *threadData, FILE_INFO info, const char *msg, ...)
{
va_list ap;
Expand Down Expand Up @@ -960,7 +963,6 @@ static void omc_assert_simulation(threadData_t *threadData, FILE_INFO info, cons
/* Ignore asserts for event search, since to find events we need to
* step over in regions, which may trigger asserts.
*/
break;
default:
throwStreamPrint(threadData,"Unhandled Assertion-Error");
}
Expand Down Expand Up @@ -996,9 +998,9 @@ static void omc_throw_simulation(threadData_t* threadData)
longjmp(*threadData->globalJumpBuffer, 1);
}

void (*omc_assert)(threadData_t*,FILE_INFO info, const char *msg, ...) = omc_assert_simulation;
void (*omc_assert)(threadData_t*,FILE_INFO info, const char *msg, ...) __attribute__ ((noreturn)) = omc_assert_simulation;
void (*omc_assert_warning)(FILE_INFO info, const char *msg, ...) = omc_assert_warning_simulation;
void (*omc_terminate)(FILE_INFO info, const char *msg, ...) = omc_terminate_simulation;
void (*omc_throw)(threadData_t*) = omc_throw_simulation;
void (*omc_throw)(threadData_t*) __attribute__ ((noreturn)) = omc_throw_simulation;

} // extern "C"
7 changes: 4 additions & 3 deletions SimulationRuntime/c/simulation/solver/events.c
Expand Up @@ -38,6 +38,7 @@
#include "simulation/simulation_runtime.h"
#include "simulation/solver/solver_main.h"
#include "simulation/solver/model_help.h"
#include "external_input.h"

#include <math.h>
#include <stdio.h>
Expand Down Expand Up @@ -130,7 +131,7 @@ int checkForStateEvent(DATA* data, LIST *eventList)

for(i=0; i<data->modelData.nZeroCrossings; i++)
{
const int *eq_indexes;
int *eq_indexes;
const char *exp_str = data->callback->zeroCrossingDescription(i,&eq_indexes);
debugStreamPrintWithEquationIndexes(LOG_EVENTS, 1, eq_indexes, "%s", exp_str);

Expand Down Expand Up @@ -221,7 +222,7 @@ void handleEvents(DATA* data, LIST* eventLst, double *eventTime, SOLVER_INFO* so
if (useStream[LOG_EVENTS]) {
for(it = listFirstNode(eventLst); it; it = listNextNode(it)) {
long ix = *((long*) listNodeData(it));
const int *eq_indexes;
int *eq_indexes;
const char *exp_str = data->callback->zeroCrossingDescription(ix,&eq_indexes);
infoStreamPrintWithEquationIndexes(LOG_EVENTS, 0, eq_indexes, "[%ld] %s", ix, exp_str);
}
Expand All @@ -238,7 +239,7 @@ void handleEvents(DATA* data, LIST* eventLst, double *eventTime, SOLVER_INFO* so
double t0 = data->simulationInfo.chatteringInfo.lastTimes[(currentIndex+1) % numEventLimit];
if (time - t0 < data->simulationInfo.stepSize) {
long ix = *((long*) listNodeData(listFirstNode(eventLst)));
const int *eq_indexes;
int *eq_indexes;
const char *exp_str = data->callback->zeroCrossingDescription(ix,&eq_indexes);
infoStreamPrintWithEquationIndexes(LOG_STDOUT, 0, eq_indexes, "Chattering detected around time %.12g..%.12g (%d state events in a row with a total time delta less than the step size %.12g). This can be a performance bottleneck. Use -lv LOG_EVENTS for more information. The zero-crossing was: %s", t0, time, numEventLimit, data->simulationInfo.stepSize, exp_str);
data->simulationInfo.chatteringInfo.messageEmitted = 1;
Expand Down
Expand Up @@ -44,7 +44,7 @@ extern "C"
{
#endif

// extern int ipopt_initialization(DATA *data, INIT_DATA *initData, int useScaling);
extern int ipopt_initialization(DATA *data, INIT_DATA *initData, int useScaling);

#ifdef __cplusplus
}
Expand Down
Expand Up @@ -703,7 +703,7 @@ int solveHybrd(DATA *data, int sysNumber)
infoStreamPrint(LOG_NLS, 1, "solution for %s at t=%g", modelInfoXmlGetEquation(&data->modelData.modelDataXml,eqSystemNumber).name, data->localData[0]->timeValue);
for(i=0; i<solverData->n; ++i)
{
infoStreamPrint(LOG_NLS, 0, "[%ld] %s = %g", i+1, modelInfoXmlGetEquation(&data->modelData.modelDataXml,eqSystemNumber).vars[i]->name, solverData->x[i]);
infoStreamPrint(LOG_NLS, 0, "[%d] %s = %g", i+1, modelInfoXmlGetEquation(&data->modelData.modelDataXml,eqSystemNumber).vars[i]->name, solverData->x[i]);
}
messageClose(LOG_NLS);
}else if (ACTIVE_STREAM(LOG_NLS_V)){
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Expand Up @@ -46,7 +46,7 @@
#include "simulation_runtime.h"

extern doublereal enorm_(integer *n, doublereal *x);

int check_nonlinear_solution(DATA *data, int printFailingSystems, int sysNumber);

const char *NLS_NAME[NLS_MAX+1] = {
"NLS_UNKNOWN",
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/simulation/solver/radau.c
Expand Up @@ -42,6 +42,7 @@
#include <string.h>

#include "radau.h"
#include "external_input.h"
#ifdef WITH_SUNDIALS

#include <kinsol/kinsol.h>
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/util/ModelicaUtilities.c
Expand Up @@ -61,7 +61,7 @@ void ModelicaError(const char* string) {
omc_throw(NULL);
}

extern void ModelicaVFormatError(const char*string, va_list args) {
void ModelicaVFormatError(const char*string, va_list args) {
vfprintf(stderr, string, args);
fflush(stderr);
omc_throw(NULL);
Expand Down
8 changes: 4 additions & 4 deletions SimulationRuntime/c/util/omc_error.h
Expand Up @@ -57,15 +57,15 @@ typedef struct _FILE_INFO
#define omc_dummyFileInfo {"",-1,-1,-1,-1,1}

extern void printInfo(FILE *stream, FILE_INFO info);
extern void (*omc_assert)(threadData_t*,FILE_INFO,const char*, ...);
extern void (*omc_assert)(threadData_t*,FILE_INFO,const char*, ...) __attribute__ ((noreturn));
extern void (*omc_assert_warning)(FILE_INFO,const char*, ...);
extern void (*omc_terminate)(FILE_INFO,const char*, ...);
extern void (*omc_throw)(threadData_t*);
extern void (*omc_throw)(threadData_t*) __attribute__ ((noreturn));
void initDumpSystem();
void omc_assert_function(threadData_t*,FILE_INFO info, const char *msg, ...);
void omc_assert_function(threadData_t*,FILE_INFO info, const char *msg, ...) __attribute__ ((noreturn));
void omc_assert_warning_function(FILE_INFO info, const char *msg, ...);
void omc_terminate_function(FILE_INFO info, const char *msg, ...);
void omc_throw_function(threadData_t*);
void omc_throw_function(threadData_t*) __attribute__ ((noreturn));

/* #define USE_DEBUG_OUTPUT */

Expand Down

0 comments on commit a424099

Please sign in to comment.