summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorMatthias Braun <matthias.braun@kit.edu>2012-07-10 15:52:01 +0200
committerMatthias Braun <matthias.braun@kit.edu>2012-07-10 15:52:01 +0200
commit31d36dd3e8a2b7b513958f005cc555e01b9c3d5b (patch)
tree416d7cfcacd3233e54eb18aa0e87c6f65c34b17b /ir/lpp
parente147f751c8a77f40096fa59cba555669e9af688b (diff)
make code C++ warning clean (again)
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp.c37
-rw-r--r--ir/lpp/lpp_comm.c17
-rw-r--r--ir/lpp/lpp_net.c3
-rw-r--r--ir/lpp/sp_matrix.c2
4 files changed, 31 insertions, 28 deletions
diff --git a/ir/lpp/lpp.c b/ir/lpp/lpp.c
index 81b210a..d6f0a77 100644
--- a/ir/lpp/lpp.c
+++ b/ir/lpp/lpp.c
@@ -47,13 +47,13 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static inline char *obst_xstrdup(struct obstack *obst, const char *str)
{
- return obstack_copy0(obst, str, strlen(str));
+ return (char*)obstack_copy0(obst, str, strlen(str));
}
static int cmp_name_t(const void *x, const void *y, size_t size)
{
- const lpp_name_t *n = x;
- const lpp_name_t *m = y;
+ const lpp_name_t *n = (const lpp_name_t*)x;
+ const lpp_name_t *m = (const lpp_name_t*)y;
(void)size;
return strcmp(n->name, m->name);
}
@@ -140,7 +140,8 @@ static int name2nr(set *where, const char *name)
{
lpp_name_t find, *found;
find.name = name;
- found = set_find(where, &find, sizeof(find), HASH_NAME_T(&find));
+ found
+ = (lpp_name_t*)set_find(where, &find, sizeof(find), HASH_NAME_T(&find));
return (found ? found->nr : -1);
}
@@ -156,7 +157,7 @@ static int var_nr(const lpp_t *lpp, const char *name)
static inline char *get_next_name(lpp_t *lpp)
{
- char *res = obstack_alloc(&lpp->obst, 12);
+ char *res = OALLOCN(&lpp->obst, char, 12);
snprintf(res, 12, "_%u", lpp->next_name_number++);
return res;
}
@@ -176,7 +177,7 @@ int lpp_add_cst(lpp_t *lpp, const char *cst_name, lpp_cst_t cst_type, double rhs
n.name = get_next_name(lpp);
n.nr = -1;
- inner = set_insert(lpp->cst2nr, &n, sizeof(n), HASH_NAME_T(&n));
+ inner = (lpp_name_t*)set_insert(lpp->cst2nr, &n, sizeof(n), HASH_NAME_T(&n));
assert(inner);
if (inner->nr == -1) {
@@ -251,12 +252,12 @@ int lpp_add_var(lpp_t *lpp, const char *var_name, lpp_var_t var_type, double obj
n.name = get_next_name(lpp);
n.nr = -1;
- inner = set_insert(lpp->var2nr, &n, sizeof(n), HASH_NAME_T(&n));
+ inner = (lpp_name_t*)set_insert(lpp->var2nr, &n, sizeof(n), HASH_NAME_T(&n));
assert(inner);
if (inner->nr == -1) {
inner->nr = lpp->var_next;
- inner->value_kind = 0;
+ inner->value_kind = lpp_none;
inner->value = 0;
inner->type.var_type = var_type;
@@ -448,7 +449,7 @@ void lpp_serialize(lpp_comm_t *comm, const lpp_t *lpp, int with_names)
lpp_writel(comm, lpp->set_bound);
lpp_writed(comm, lpp->bound);
lpp_writed(comm, lpp->time_limit_secs);
- lpp_writed(comm, lpp->emphasis);
+ lpp_writel(comm, lpp->emphasis);
for(i = 0; i < lpp->cst_next; ++i) {
lpp_name_t *name = lpp->csts[i];
@@ -503,14 +504,14 @@ lpp_t *lpp_deserialize(lpp_comm_t *comm)
with_names = lpp_readl(comm);
lpp->cst_next = lpp_readl(comm);
lpp->var_next = lpp_readl(comm);
- lpp->opt_type = lpp_readl(comm);
+ lpp->opt_type = (lpp_opt_t)lpp_readl(comm);
lpp->name = lpp_reads(comm);
/* read options */
lpp->set_bound = lpp_readl(comm);
lpp->bound = lpp_readd(comm);
lpp->time_limit_secs = lpp_readd(comm);
- lpp->emphasis = lpp_readd(comm);
+ lpp->emphasis = (lpp_emphasis_t)lpp_readl(comm);
lpp->cst_size = lpp->cst_next;
lpp->var_size = lpp->var_next;
@@ -526,8 +527,8 @@ lpp_t *lpp_deserialize(lpp_comm_t *comm)
lpp_name_t name, *res;
name.nr = lpp_readl(comm);
- name.value_kind = lpp_readl(comm);
- name.type.cst_type = lpp_readl(comm);
+ name.value_kind = (lpp_value_kind_t)lpp_readl(comm);
+ name.type.cst_type = (lpp_cst_t)lpp_readl(comm);
if(with_names) {
name.name = lpp_reads(comm);
@@ -537,7 +538,7 @@ lpp_t *lpp_deserialize(lpp_comm_t *comm)
name.name = buf;
}
- res = set_insert(lpp->cst2nr, &name, sizeof(name), HASH_NAME_T(&name));
+ res = (lpp_name_t*)set_insert(lpp->cst2nr, &name, sizeof(name), HASH_NAME_T(&name));
lpp->csts[name.nr] = res;
}
@@ -545,8 +546,8 @@ lpp_t *lpp_deserialize(lpp_comm_t *comm)
lpp_name_t name, *res;
name.nr = lpp_readl(comm);
- name.value_kind = lpp_readl(comm);
- name.type.var_type = lpp_readl(comm);
+ name.value_kind = (lpp_value_kind_t)lpp_readl(comm);
+ name.type.var_type = (lpp_var_t)lpp_readl(comm);
if(with_names) {
name.name = lpp_reads(comm);
@@ -556,7 +557,7 @@ lpp_t *lpp_deserialize(lpp_comm_t *comm)
name.name = buf;
}
- res = set_insert(lpp->var2nr, &name, sizeof(name), HASH_NAME_T(&name));
+ res = (lpp_name_t*)set_insert(lpp->var2nr, &name, sizeof(name), HASH_NAME_T(&name));
lpp->vars[name.nr] = res;
}
@@ -619,7 +620,7 @@ void lpp_serialize_stats(lpp_comm_t *comm, const lpp_t *lpp)
void lpp_deserialize_stats(lpp_comm_t *comm, lpp_t *lpp)
{
- lpp->sol_state = lpp_readl(comm);
+ lpp->sol_state = (lpp_sol_state_t)lpp_readl(comm);
lpp->iterations = lpp_readl(comm);
lpp->sol_time = lpp_readd(comm);
lpp->objval = lpp_readd(comm);
diff --git a/ir/lpp/lpp_comm.c b/ir/lpp/lpp_comm.c
index 4af7b41..bcfa974 100644
--- a/ir/lpp/lpp_comm.c
+++ b/ir/lpp/lpp_comm.c
@@ -40,6 +40,7 @@
#include <arpa/inet.h>
#endif
+#include "xmalloc.h"
#include "util.h"
#include "debug.h"
@@ -80,7 +81,7 @@ static ssize_t secure_recv(int fd, void *buf, size_t try_amount, size_t at_least
{
ssize_t res;
size_t bytes_read = 0;
- char *data = buf;
+ char *data = (char*)buf;
do {
res = recv(fd, &data[bytes_read], try_amount - bytes_read, 0);
@@ -101,7 +102,7 @@ static ssize_t secure_send(int fd, const void *buf, size_t n)
{
ssize_t res;
size_t bytes_written = 0;
- const char *data = buf;
+ const char *data = (const char*)buf;
do {
res = send(fd, &data[bytes_written], n - bytes_written, 0);
@@ -141,7 +142,7 @@ static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
size_t free = (comm->w_buf + comm->buf_size) - comm->w_pos;
size_t copy = MIN(free, len);
size_t rest = len - copy;
- const char *pos = buf;
+ const char *pos = (const char*)buf;
DBG((dbg, LEVEL_1, "\tfree = %d, copy = %d, rest = %d\n", free, copy, rest));
if(copy > 0) {
@@ -190,7 +191,7 @@ static ssize_t lpp_read(lpp_comm_t *comm, void *buf, size_t len)
size_t left = comm->r_max - comm->r_pos;
size_t copy = MIN(left, len);
size_t rest = len - copy;
- char *pos = buf;
+ char *pos = (char*)buf;
DBG((dbg, LEVEL_1, "\tleft = %d, copy = %d, rest = %d\n", left, copy, rest));
if(copy > 0) {
@@ -244,12 +245,12 @@ static ssize_t lpp_read(lpp_comm_t *comm, void *buf, size_t len)
lpp_comm_t *lpp_comm_new(int fd, size_t buf_size)
{
- lpp_comm_t *res = malloc(sizeof(res[0]));
+ lpp_comm_t *res = XMALLOCZ(lpp_comm_t);
res->fd = fd;
- res->w_buf = malloc(buf_size);
+ res->w_buf = XMALLOCN(char, buf_size);
res->w_pos = res->w_buf;
- res->r_buf = malloc(buf_size);
+ res->r_buf = XMALLOCN(char, buf_size);
res->r_pos = res->r_buf;
res->r_max = res->r_buf;
res->buf_size = buf_size;
@@ -333,7 +334,7 @@ double lpp_readd(lpp_comm_t *comm)
char *lpp_reads(lpp_comm_t *comm)
{
size_t len = lpp_readl(comm);
- char *res = malloc(sizeof(char) * (len + 1));
+ char *res = XMALLOCN(char, len+1);
ERRNO_CHECK(lpp_read(comm, res, len), !=, (ssize_t) len);
res[len] = '\0';
diff --git a/ir/lpp/lpp_net.c b/ir/lpp/lpp_net.c
index 3ff6a56..c8799a6 100644
--- a/ir/lpp/lpp_net.c
+++ b/ir/lpp/lpp_net.c
@@ -59,6 +59,7 @@
#include "lpp_net.h"
#include "lpp_t.h"
#include "lpp_comm.h"
+#include "xmalloc.h"
#ifdef _WIN32
static int winsock_init(void)
@@ -136,7 +137,7 @@ char **lpp_get_solvers(const char *host)
lpp_writel(comm, LPP_CMD_SOLVERS);
lpp_flush(comm);
n = lpp_readl(comm);
- res = malloc((n + 1) * sizeof(res[0]));
+ res = XMALLOCN(char*, n+1);
res[n] = NULL;
if(n > 0) {
diff --git a/ir/lpp/sp_matrix.c b/ir/lpp/sp_matrix.c
index bda1933..500ba2e 100644
--- a/ir/lpp/sp_matrix.c
+++ b/ir/lpp/sp_matrix.c
@@ -645,7 +645,7 @@ void matrix_optimize(sp_matrix_t *m)
}
}
- c = alloca(size * sizeof(*c));
+ c = ALLOCAN(int, size);
redo = 1;
fullrow = bitset_alloca(size);