summaryrefslogtreecommitdiffstats
path: root/src/simfs.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-10-22 11:45:39 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-10-22 11:45:39 -0500
commit71255c49fb2802f925b60f7a03b7b6ac2a9a2d2d (patch)
tree5a86663db8ccb3899f22b28b1c4c6eb9f6ccf14e /src/simfs.c
parent6ce608b01ded2b6dae56225fd791ffd2c83fa17d (diff)
downloadofono-71255c49fb2802f925b60f7a03b7b6ac2a9a2d2d.tar.bz2
simfs: Use errno for simfs errors
Diffstat (limited to 'src/simfs.c')
-rw-r--r--src/simfs.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/simfs.c b/src/simfs.c
index 7c7ea97b..6e2b5690 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -669,18 +669,20 @@ int sim_fs_read_info(struct sim_fs *fs, int id,
struct sim_fs_op *op;
if (!cb)
- return -1;
+ return -EINVAL;
if (!fs->driver)
- return -1;
+ return -EINVAL;
if (!fs->driver->read_file_info)
- return -1;
+ return -ENOSYS;
if (!fs->op_q)
fs->op_q = g_queue_new();
- op = g_new0(struct sim_fs_op, 1);
+ op = g_try_new0(struct sim_fs_op, 1);
+ if (op == NULL)
+ return -ENOMEM;
op->id = id;
op->structure = expected_type;
@@ -705,18 +707,20 @@ int sim_fs_read(struct sim_fs *fs, int id,
struct sim_fs_op *op;
if (!cb)
- return -1;
+ return -EINVAL;
if (!fs->driver)
- return -1;
+ return -EINVAL;
if (!fs->driver->read_file_info)
- return -1;
+ return -ENOSYS;
if (!fs->op_q)
fs->op_q = g_queue_new();
- op = g_new0(struct sim_fs_op, 1);
+ op = g_try_new0(struct sim_fs_op, 1);
+ if (op == NULL)
+ return -ENOMEM;
op->id = id;
op->structure = expected_type;
@@ -743,10 +747,10 @@ int sim_fs_write(struct sim_fs *fs, int id, ofono_sim_file_write_cb_t cb,
gconstpointer fn = NULL;
if (!cb)
- return -1;
+ return -EINVAL;
if (!fs->driver)
- return -1;
+ return -EINVAL;
switch (structure) {
case OFONO_SIM_FILE_STRUCTURE_TRANSPARENT:
@@ -763,12 +767,14 @@ int sim_fs_write(struct sim_fs *fs, int id, ofono_sim_file_write_cb_t cb,
}
if (fn == NULL)
- return -1;
+ return -ENOSYS;
if (!fs->op_q)
fs->op_q = g_queue_new();
- op = g_new0(struct sim_fs_op, 1);
+ op = g_try_new0(struct sim_fs_op, 1);
+ if (op == NULL)
+ return -ENOMEM;
op->id = id;
op->cb = cb;