Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 8e5affa

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Fix wrong pointer type
Added detection of wrong pointer types being sent using -Werror and fixed the errors caused by it. Belonging to [master]: - #2134
1 parent a7e840a commit 8e5affa

File tree

14 files changed

+10
-74
lines changed

14 files changed

+10
-74
lines changed

Compiler/Util/System.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ function stringAllocatorResult<T>
12641264
input T dummy "This is just added so we do not make an extra allocation for the string" annotation(__OpenModelica_UnusedVariable=true);
12651265
output T res;
12661266
external "C" res=om_stringAllocatorResult(sa) annotation(Include="
1267-
const char* om_stringAllocatorResult(void *sa) {
1267+
void* om_stringAllocatorResult(void *sa) {
12681268
return sa;
12691269
}
12701270
");

Compiler/boot/Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ bootstrap-from-tarball: $(PATCHES)
6060
tar xJf bootstrap-sources.tar.xz
6161
# Patch _main.c to avoid a new tarball
6262
$(PATCH_SOURCES)
63-
cd build && for x in ../patches/*.patch; do patch -i "$$x" "`basename $$x | $(SED) 's/\([.][0-9]*\)\?[.]patch/.c/'`" || exit 1; done
63+
cd build && for x in ../patches/*.patch; do patch -i "$$x" "`basename $$x | $(SED) 's/\([.][0-9]*\)\?[.]patch//'`" || exit 1; done
6464
# We have not compiled OpenModelicaScriptingAPI.mo yet
6565
touch build/OpenModelicaScriptingAPI.h
6666
$(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC=.omc BOOTSTRAP_STAGE_1=1 CPPFLAGS="$(CPPFLAGS) -DOMC_BOOTSTRAPPING_STAGE_1"
312 Bytes
Binary file not shown.

Parser/BaseModelica_Lexer.g

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ STRING : '"' STRING_GUTS '"'
333333
pANTLR3_STRING text = $STRING_GUTS.text;
334334
char *res = 0;
335335
if (*text->chars) {
336-
res = SystemImpl__iconv((const char*)text->chars,ModelicaParser_encoding,"UTF-8",0);
336+
res = (char*) SystemImpl__iconv((const char*)text->chars,ModelicaParser_encoding,"UTF-8",0);
337337
if (!*res) {
338338
const char *strs[2];
339339
signed char buf[76];
340340
int len, i;
341-
res = SystemImpl__iconv__ascii((const char*)text->chars);
341+
res = (char*) SystemImpl__iconv__ascii((const char*)text->chars);
342342
len = strlen((const char*)res);
343343
/* Avoid printing huge strings */
344344
if (len > 75) {

Parser/ModelicaParserCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ DLLDirection extern pthread_key_t modelicaParserKey;
5353
#define ModelicaParser_langStd ((parser_members*)pthread_getspecific(modelicaParserKey))->langStd
5454
#define ModelicaParser_lexerError ((parser_members*)pthread_getspecific(modelicaParserKey))->lexerError
5555
#define ModelicaParser_encoding ((parser_members*)pthread_getspecific(modelicaParserKey))->encoding
56-
#define ModelicaParser_threadData ((parser_members*)pthread_getspecific(mmc_thread_data_key))
56+
#define ModelicaParser_threadData ((threadData_t*)pthread_getspecific(mmc_thread_data_key))
5757

5858
typedef struct antlr_members_struct {
5959
int lexerError;

SimulationRuntime/c/optimization/OptimizerData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct OptDataDim{
5353
int NRes;
5454
int nJ;
5555
int nJ2;
56-
int nsi;
56+
modelica_integer nsi;
5757
int nt;
5858

5959
int np;

SimulationRuntime/c/simulation/solver/ida_solver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ int residualFunctionIDA(double time, N_Vector yy, N_Vector yp, N_Vector res, voi
10991099
for(i=0; i < idaData->N; i++)
11001100
{
11011101
NV_Ith_S(res, i) = data->simulationInfo->daeModeData->residualVars[i];
1102-
infoStreamPrint(LOG_SOLVER_V, 0, "%d. residual = %e", i, NV_Ith_S(res, i));
1102+
infoStreamPrint(LOG_SOLVER_V, 0, "%ld. residual = %e", i, NV_Ith_S(res, i));
11031103
}
11041104
}
11051105
else
@@ -1109,7 +1109,7 @@ int residualFunctionIDA(double time, N_Vector yy, N_Vector yp, N_Vector res, voi
11091109
for(i=0; i < idaData->N; i++)
11101110
{
11111111
NV_Ith_S(res, i) = data->localData[0]->realVars[data->modelData->nStates + i] - NV_Ith_S(yp, i);
1112-
infoStreamPrint(LOG_SOLVER_V, 0, "%d. residual = %e", i, NV_Ith_S(res, i));
1112+
infoStreamPrint(LOG_SOLVER_V, 0, "%ld. residual = %e", i, NV_Ith_S(res, i));
11131113
}
11141114
}
11151115

SimulationRuntime/c/util/boolean_array.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -522,22 +522,6 @@ void array_alloc_boolean_array(boolean_array_t* dest, int n,
522522
free(elts);
523523
}
524524

525-
void array_scalar_boolean_array(boolean_array_t* dest, int n,
526-
m_boolean first, ...)
527-
{
528-
int i;
529-
va_list ap;
530-
assert(base_array_ok(dest));
531-
assert(dest->ndims == 1);
532-
assert(dest->dim_size[0] == n);
533-
put_boolean_element(first, 0, dest);
534-
va_start(ap,first);
535-
for(i = 0; i < n; ++i) {
536-
put_boolean_element((m_boolean) va_arg(ap, int),i,dest);
537-
}
538-
va_end(ap);
539-
}
540-
541525
/* array_alloc_scalar_boolean_array
542526
*
543527
* Creates(incl allocation) an array from scalar elements.

SimulationRuntime/c/util/boolean_array.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ extern void array_alloc_boolean_array(boolean_array_t* dest,int n,
150150
boolean_array_t first,...);
151151

152152
/* array(s1,s2,s3) for scalars s1,s2,s3 */
153-
extern void array_scalar_boolean_array(boolean_array_t* dest,int n,
154-
m_boolean first,...);
153+
extern void array_scalar_boolean_array(boolean_array_t* dest,int n,...);
155154
extern void array_alloc_scalar_boolean_array(boolean_array_t* dest,int n,...);
156155

157156
extern m_boolean* boolean_array_element_addr(const boolean_array_t* source,int ndims,...);

0 commit comments

Comments
 (0)