From 657eec7ee5a276521eb456bf648878935e794b6e Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 8 Mar 2011 13:32:10 +0100 Subject: Clean up struct rs_error somewhat. More to be done here! --- lib/err.c | 19 +++++-------------- lib/examples/client-blocking.c | 2 +- lib/include/radsec/radsec-impl.h | 1 - 3 files changed, 6 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/err.c b/lib/err.c index 55fc5de..e2112c3 100644 --- a/lib/err.c +++ b/lib/err.c @@ -178,7 +178,9 @@ rs_err_conn_pop (struct rs_connection *conn) int rs_err_conn_peek_code (struct rs_connection *conn) { - if (conn && conn->err) + if (!conn) + return -1; /* FIXME: RSE_INVALID_CONN */ + if (conn->err) return conn->err->code; else return RSE_OK; @@ -188,26 +190,15 @@ void rs_err_free (struct rs_error *err) { assert (err); - if (err->msg) - free (err->msg); free (err); } char * -rs_err_msg (struct rs_error *err, int dofree_flag) +rs_err_msg (struct rs_error *err) { - char *msg; - if (!err) return NULL; - if (err->msg) - msg = err->msg; - else - msg = strdup (err->buf); - - if (dofree_flag) - rs_err_free (err); - return msg; + return err->buf; } int diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 31fd6d1..ef361e5 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -100,7 +100,7 @@ main (int argc, char *argv[]) err = blocking_client (argv[1], argv[2], use_request_object_flag); if (err) { - fprintf (stderr, "%s\n", rs_err_msg (err, 0)); + fprintf (stderr, "%s\n", rs_err_msg (err)); return rs_err_code (err, 1); } return 0; diff --git a/lib/include/radsec/radsec-impl.h b/lib/include/radsec/radsec-impl.h index e790ccf..a924fc9 100644 --- a/lib/include/radsec/radsec-impl.h +++ b/lib/include/radsec/radsec-impl.h @@ -32,7 +32,6 @@ struct rs_credentials { struct rs_error { int code; - char *msg; char buf[1024]; }; -- cgit v1.1