Skip to content

Commit

Permalink
Static analysis fixes
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24729 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 24, 2015
1 parent e2ac4ce commit 1888eca
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
11 changes: 4 additions & 7 deletions Compiler/runtime/Dynload.cpp
Expand Up @@ -37,6 +37,7 @@ extern "C" {
#include "modelica.h"
#include "systemimpl.h"
#include "errorext.h"
#include "meta_modelica_builtin.h"

#define MMC_NUM_ARGS 32
#define UNBOX_OFFSET 1
Expand Down Expand Up @@ -78,7 +79,6 @@ static int value_to_type_desc(void *value, type_description *desc)
}; break;
case Values__STRING_3dBOX1: {
void *data = MMC_STRUCTDATA(value)[UNBOX_OFFSET];
int len = MMC_HDRSTRLEN(MMC_GETHDR(data));
desc->type = TYPE_DESC_STRING;
desc->data.string = data;
}; break;
Expand Down Expand Up @@ -524,15 +524,14 @@ static void *value_to_mmc(void* value)
while (MMC_GETHDR(tmp) != MMC_NILHDR) {
len++; tmp = MMC_CDR(tmp);
}
data_mmc = (void**) malloc(len*sizeof(void*));
res = mmc_mk_box_no_assign(len, 0);
len = 0;
tmp = data;
while (MMC_GETHDR(tmp) != MMC_NILHDR) {
data_mmc[len++] = value_to_mmc(MMC_CAR(tmp));
threadData_t *threadData = NULL;
arrayUpdate(res, ++len, value_to_mmc(MMC_CAR(tmp)));
tmp = MMC_CDR(tmp);
}
res = mmc_mk_box_arr(len, 0, (void**) data_mmc);
free(data_mmc);
return res;
};
case Values__ENUM_5fLITERAL_3dBOX2:
Expand Down Expand Up @@ -720,12 +719,10 @@ static int get_array_data(int curdim, int dims, const _index_t *dim_size,
}; break;
case TYPE_DESC_STRING: {
modelica_string *ptr = *((modelica_string**)data);
int len;
void *str;
if (MMC_HDRCTOR(MMC_GETHDR(item)) != Values__STRING_3dBOX1)
return -1;
str = MMC_STRUCTDATA(item)[UNBOX_OFFSET+0];
len = MMC_HDRSTRLEN(MMC_GETHDR(str));
*ptr = str;
*data = ++ptr;
}; break;
Expand Down
3 changes: 0 additions & 3 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -865,7 +865,6 @@ static inline unsigned long djb2_hash_iter(const unsigned char *str /* data; not

unsigned long mmc_prim_hash(void *p,unsigned long hash /* start at 5381 */)
{
void **pp = NULL;
mmc_uint_t phdr = 0;

mmc_prim_hash_tail_recur:
Expand Down Expand Up @@ -893,8 +892,6 @@ unsigned long mmc_prim_hash(void *p,unsigned long hash /* start at 5381 */)
int i;
int slots = MMC_HDRSLOTS(phdr);
int ctor = MMC_HDRCTOR(phdr);
int is_record = slots>0 && ctor > 1 ? 1 : 0;
pp = MMC_STRUCTDATA(p);
hash = djb2_hash_iter((unsigned char*)&ctor, sizeof(int), hash);
if (slots == 0)
return hash;
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/meta_modelica_segv.c
Expand Up @@ -98,7 +98,7 @@ static sigset_t segvset;

static void handler(int signo, siginfo_t *si, void *ptr)
{
int isStackOverflow,unused;
int unused __attribute__((unused)), isStackOverflow;
isStackOverflow = si->si_addr < stackBottom && (si->si_addr > stackBottom - LIMIT_FOR_STACK_OVERFLOW);
if (isStackOverflow) {
setTrace(1,0);
Expand Down
6 changes: 3 additions & 3 deletions SimulationRuntime/c/simulation/simulation_info_json.c
Expand Up @@ -135,7 +135,7 @@ static const char* skipValue(const char* str)
case '9':
{
char *endptr = NULL;
double d = strtod(str,&endptr);
strtod(str,&endptr);
if (str == endptr) {
fprintf(stderr, "Not a number, got %.20s\n", str);
abort();
Expand Down Expand Up @@ -253,7 +253,7 @@ static const char* readEquation(const char *str,EQUATION_INFO *xml,int i)
}
str++;
};
str = assertChar(str, ']');
assertChar(str, ']');
xml->numVar = n;
xml->vars = malloc(sizeof(const char*)*n);
str = str2;
Expand Down Expand Up @@ -363,7 +363,7 @@ static void readInfoJson(const char *str,MODEL_DATA_XML *xml)
str=assertStringValue(str,"functions");
str=assertChar(str,':');
str=readFunctions(str,xml);
str=assertChar(str,'}');
assertChar(str,'}');
}

void modelInfoJsonInit(MODEL_DATA_XML* xml)
Expand Down
2 changes: 0 additions & 2 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -411,7 +411,6 @@ int startNonInteractiveSimulation(int argc, char**argv, DATA* data)
TRACE_PUSH

int retVal = -1;
int measureSimTime = 0;

/* linear model option is set : <-l lintime> */
int create_linearmodel = omc_flag[FLAG_L];
Expand All @@ -422,7 +421,6 @@ int startNonInteractiveSimulation(int argc, char**argv, DATA* data)
if (!measure_time_flag && (ACTIVE_STREAM(LOG_STATS) || omc_flag[FLAG_CPU]))
{
measure_time_flag = 1;
measureSimTime = 1;
}
errno = 0;
if (omc_flag[FLAG_ALARM]) {
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/simulation/solver/dassl.c
Expand Up @@ -166,7 +166,6 @@ int dassl_initial(DATA* data, SOLVER_INFO* solverInfo, DASSL_DATA *dasslData)
{
/* work arrays for DASSL */
unsigned int i;
SIMULATION_INFO *simInfo = &(data->simulationInfo);
SIMULATION_DATA tmpSimData = {0};

TRACE_PUSH
Expand Down

0 comments on commit 1888eca

Please sign in to comment.