Skip to content

Commit

Permalink
- Fixed clang warnings in the compiler runtime.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15465 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Mar 4, 2013
1 parent 4a53786 commit a1ed8b8
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 26 deletions.
18 changes: 2 additions & 16 deletions Compiler/runtime/Database.c
Expand Up @@ -52,6 +52,8 @@
#define DATABASE_MAX_DATABASES 1024
sqlite3 *DATABASES[1024] = {0};

static int callback(void *result, int argc, char **argv, char **azColName);

int checkIndex(int index)
{
if (index >= DATABASE_MAX_DATABASES || index < 0)
Expand All @@ -67,22 +69,6 @@ void DatabaseImpl_init(void)
// do nothing for now
}

static int callback(void *result, int argc, char **argv, char **azColName){
int i;
void** res = (void**)result;
for(i = 0; i < argc; i++)
{
/* the result is a list of string tuples (name, value)*/
*res = mk_cons(
mk_box2(
0,
mk_scon(azColName[i]),
mk_scon(argv[i] ? argv[i] : "NULL")),
*res);
}
return 0;
}

int DatabaseImpl_open(int index, const char* name)
{
int rc = checkIndex(index);
Expand Down
27 changes: 21 additions & 6 deletions Compiler/runtime/Database_omc.c
@@ -1,21 +1,36 @@

#include "meta_modelica.h"
#include "Database.c"

void Database_init(void)
{
DatbaseImpl_init();
DatabaseImpl_init();
}

int Database_open(int index, const char* _name)
{
return DatbaseImpl_open(index, _name);
return DatabaseImpl_open(index, _name);
}

void* Database_query(int index, const char* _sql)
{
void* result = mk_nil();
if (DatbaseImpl_query(index, _sql, &result))
return mk_nil();
void* result = mmc_mk_nil();
if (DatabaseImpl_query(index, _sql, &result))
return mmc_mk_nil();
return result;
}

static int callback(void *result, int argc, char **argv, char **azColName){
int i;
void** res = (void**)result;
for(i = 0; i < argc; i++)
{
/* the result is a list of string tuples (name, value)*/
*res = mmc_mk_cons(
mmc_mk_box2(
0,
mmc_mk_scon(azColName[i]),
mmc_mk_scon(argv[i] ? argv[i] : "NULL")),
*res);
}
return 0;
}
15 changes: 15 additions & 0 deletions Compiler/runtime/Database_rml.c
Expand Up @@ -30,3 +30,18 @@ RML_BEGIN_LABEL(Database__query)
}
RML_END_LABEL

static int callback(void *result, int argc, char **argv, char **azColName){
int i;
void** res = (void**)result;
for(i = 0; i < argc; i++)
{
/* the result is a list of string tuples (name, value)*/
*res = mk_cons(
mk_box2(
0,
mk_scon(azColName[i]),
mk_scon(argv[i] ? argv[i] : "NULL")),
*res);
}
return 0;
}
2 changes: 2 additions & 0 deletions Compiler/runtime/FMIImpl.c
Expand Up @@ -37,6 +37,7 @@ extern "C" {

#include "systemimpl.h"
#include "errorext.h"
#include "modelica_string.h"

#define FMILIB_BUILDING_LIBRARY
#include "fmilib.h"
Expand Down Expand Up @@ -468,6 +469,7 @@ void FMIImpl__initializeFMI2Import(fmi2_import_t* fmi, void** fmiInfo, fmi_versi
case fmi2_fmu_kind_cs:
modelIdentifier = fmi2_import_get_model_identifier_CS(fmi);
break;
default: break;
}
/* Read the FMI GUID from FMU's modelDescription.xml file. */
const char* guid = fmi2_import_get_GUID(fmi);
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/ModelicaExternalC_rml.c
Expand Up @@ -40,6 +40,7 @@ void ModelicaInternal_print(const char*,const char*);
const char* ModelicaInternal_readLine(const char*,int,int*);
int ModelicaInternal_countLines(const char*);
const char* ModelicaInternal_fullPathName(const char*);
int ModelicaInternal_stat(const char*);
void ModelicaStreams_closeFile(const char*);
void ModelicaStrings_scanReal(const char*,int,int,int*,double*);
int ModelicaStrings_skipWhiteSpace(const char*,int);
Expand Down
2 changes: 2 additions & 0 deletions Compiler/runtime/Print_rml.c
Expand Up @@ -68,12 +68,14 @@ RML_BEGIN_LABEL(Print__setBufSize)
{
long newSize = (long)RML_UNTAGFIXNUM(rmlA0); // adrpo: do not use RML_IMMEDIATE as is just a cast to void! IS NOT NEEDED!
PrintImpl__setBufSize(newSize);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(Print__unSetBufSize)
{
PrintImpl__unSetBufSize();
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

Expand Down
2 changes: 0 additions & 2 deletions Compiler/runtime/omc_communication_impl.cpp
Expand Up @@ -108,8 +108,6 @@ extern bool corba_waiting;
extern char* omc_cmd_message;
extern char* omc_reply_message;

using namespace std;

//This is the implementation of the omc communication using mico (CORBA)

OmcCommunication_impl::OmcCommunication_impl()
Expand Down
4 changes: 2 additions & 2 deletions Compiler/runtime/printimpl.c
Expand Up @@ -348,7 +348,7 @@ static int PrintImpl__hasBufNewLineAtEnd(void)
static int PrintImpl__restoreBuf(long handle)
{
if (handle < 0 || handle > MAXSAVEDBUFFERS-1) {
fprintf(stderr,"Internal error, hanlde %d out of range. Should be in [%d,&d]\n",handle,0,MAXSAVEDBUFFERS-1);
fprintf(stderr,"Internal error, handle %ld out of range. Should be in [%d,%d]\n",handle,0,MAXSAVEDBUFFERS-1);
return 1;
} else {
if (buf) { free(buf);}
Expand All @@ -359,7 +359,7 @@ static int PrintImpl__restoreBuf(long handle)
savedCurSize[handle] = 0;
savedNfilled[handle] = 0;
if (buf == 0) {
fprintf(stderr,"Internal error, handle %d does not contain a valid buffer pointer\n",handle);
fprintf(stderr,"Internal error, handle %ld does not contain a valid buffer pointer\n",handle);
return 1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/socketimpl.c
Expand Up @@ -38,4 +38,5 @@
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#endif

0 comments on commit a1ed8b8

Please sign in to comment.