Several improves in error codes.

- Code severity and priority in error codes.
- Added ERROR severity, suitable for function failures.
- Review libisofs errors and its severity.
This commit is contained in:
Vreixo Formoso 2008-01-20 22:28:27 +01:00
parent a076ae9df2
commit 1070fe4cc6
23 changed files with 331 additions and 211 deletions

View File

@ -84,14 +84,14 @@ int iso_ring_buffer_new(size_t size, IsoRingBuffer **rbuf)
buffer = malloc(sizeof(IsoRingBuffer));
if (buffer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
buffer->cap = (size > 32 ? size : 32) * BLOCK_SIZE;
buffer->buf = malloc(buffer->cap);
if (buffer->buf == NULL) {
free(buffer);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
buffer->size = 0;

View File

@ -58,7 +58,7 @@ int default_create_file(IsoNodeBuilder *builder, IsoImage *image,
/* the stream has taken our ref to src, so we need to add one */
iso_file_source_ref(src);
iso_stream_unref(stream);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill node fields */
@ -125,7 +125,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
if (file == NULL) {
free(name);
iso_stream_unref(stream);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
file->msblock = 0;
file->sort_weight = 0;
@ -140,7 +140,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
new = calloc(1, sizeof(IsoDir));
if (new == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
new->type = LIBISO_DIR;
}
@ -159,7 +159,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
link = malloc(sizeof(IsoSymlink));
if (link == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
link->dest = strdup(dest);
link->node.type = LIBISO_SYMLINK;
@ -176,7 +176,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
special = malloc(sizeof(IsoSpecial));
if (special == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
special->dev = info.st_rdev;
special->node.type = LIBISO_SPECIAL;
@ -220,7 +220,7 @@ int iso_node_basic_builder_new(IsoNodeBuilder **builder)
b = malloc(sizeof(IsoNodeBuilder));
if (b == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
b->refcount = 1;

View File

@ -164,13 +164,13 @@ int iso_data_source_new_from_file(const char *path, IsoDataSource **src)
data = malloc(sizeof(struct file_data_src));
if (data == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ds = malloc(sizeof(IsoDataSource));
if (ds == NULL) {
free(data);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill data fields */
@ -178,7 +178,7 @@ int iso_data_source_new_from_file(const char *path, IsoDataSource **src)
if (data->path == NULL) {
free(data);
free(ds);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
data->fd = -1;

View File

@ -197,7 +197,7 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
uint32_t path_table_size;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
target = writer->target;
@ -307,7 +307,7 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
char *abstract_file_id, *biblio_file_id;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -555,7 +555,7 @@ int write_path_tables(Ecma119Image *t)
/* allocate temporal pathlist */
pathlist = malloc(sizeof(void*) * t->ndirs);
if (pathlist == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
pathlist[0] = t->root;
cur = 1;
@ -625,7 +625,7 @@ int ecma119_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = ecma119_writer_compute_data_blocks;
@ -656,7 +656,7 @@ int pad_writer_compute_data_blocks(IsoImageWriter *writer)
Ecma119Image *target;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
target = writer->target;
@ -682,7 +682,7 @@ int pad_writer_write_data(IsoImageWriter *writer)
size_t i;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -715,7 +715,7 @@ int pad_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = pad_writer_compute_data_blocks;
@ -806,7 +806,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
/* 1. Allocate target and copy opts there */
target = calloc(1, sizeof(Ecma119Image));
if (target == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* create the tree for file caching */
@ -859,7 +859,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
if (target->input_charset == NULL) {
iso_image_unref(src);
free(target);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
if (opts->output_charset != NULL) {
@ -870,7 +870,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
if (target->output_charset == NULL) {
iso_image_unref(src);
free(target);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/*
@ -900,7 +900,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
if (target->writers == NULL) {
iso_image_unref(src);
free(target);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* create writer for ECMA-119 structure */
@ -1130,7 +1130,7 @@ int iso_image_create_burn_source(IsoImage *image, Ecma119WriteOpts *opts,
source = calloc(1, sizeof(struct burn_source));
if (source == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ret = ecma119_image_new(image, opts, &target);
@ -1157,7 +1157,7 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
ret = iso_ring_buffer_write(target->buffer, buf, count);
if (ret == 0) {
/* reader cancelled */
return ISO_WRITE_ERROR;
return ISO_CANCELED;
}
/* total size is 0 when writing the overwrite buffer */

View File

@ -89,7 +89,7 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
* only possible if mem error, as check for empty names is done
* in public tree
*/
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
}
@ -100,7 +100,7 @@ int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node)
ecma = calloc(1, sizeof(Ecma119Node));
if (ecma == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* take a ref to the IsoNode */
@ -128,13 +128,13 @@ int create_dir(Ecma119Image *img, IsoDir *iso, Ecma119Node **node)
children = calloc(1, sizeof(void*) * iso->nchildren);
if (children == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
dir_info = calloc(1, sizeof(struct ecma119_dir_info));
if (dir_info == NULL) {
free(children);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ret = create_ecma119_node(img, (IsoNode*)iso, node);
@ -379,7 +379,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
break;
default:
/* should never happen */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
if (ret <= 0) {
free(iso_name);
@ -568,7 +568,7 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
if (ok) {
char *new = strdup(tmp);
if (new == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto mangle_cleanup;
}
iso_msg_debug(img->image->id,
@ -677,7 +677,7 @@ int create_placeholder(Ecma119Node *parent, Ecma119Node *real,
ret = calloc(1, sizeof(Ecma119Node));
if (ret == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/*
@ -688,7 +688,7 @@ int create_placeholder(Ecma119Node *parent, Ecma119Node *real,
ret->iso_name = strdup(real->iso_name);
if (ret->iso_name == NULL) {
free(ret);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* take a ref to the IsoNode */
@ -742,7 +742,7 @@ int reparent(Ecma119Node *child, Ecma119Node *parent)
/* just for debug, this should never happen... */
if (i == child->parent->info.dir->nchildren) {
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
/* keep track of the real parent */
@ -816,7 +816,7 @@ int ecma119_tree_create(Ecma119Image *img)
if (ret <= 0) {
if (ret == 0) {
/* unexpected error, root ignored!! This can't happen */
ret = ISO_ERROR;
ret = ISO_ASSERT_FAILURE;
}
return ret;
}

View File

@ -128,7 +128,7 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
node = calloc(1, sizeof(IsoBoot));
if (node == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->node.refcount = 1;
@ -136,7 +136,7 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
node->node.name = strdup(name);
if (node->node.name == NULL) {
free(node);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* atributes from parent */
@ -181,7 +181,7 @@ int create_image(IsoImage *image, const char *image_path,
return ret;
}
if (ret == 0) {
return ISO_FILE_DOESNT_EXIST;
return ISO_NODE_DOESNT_EXIST;
}
if (imgfile->type != LIBISO_FILE) {
@ -274,7 +274,7 @@ int create_image(IsoImage *image, const char *image_path,
boot = calloc(1, sizeof(struct el_torito_boot_image));
if (boot == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
boot->image = (IsoFile*)imgfile;
iso_node_ref(imgfile); /* get our ref */
@ -313,7 +313,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
char *catdir = NULL, *catname = NULL;
catdir = strdup(catalog_path);
if (catdir == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* get both the dir and the name */
@ -331,7 +331,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
ret = iso_tree_path_to_node(image, catdir, &p);
if (ret <= 0) {
free(catdir);
return ret < 0 ? ret : ISO_FILE_DOESNT_EXIST;
return ret < 0 ? ret : ISO_NODE_DOESNT_EXIST;
}
if (p->type != LIBISO_DIR) {
free(catdir);
@ -356,7 +356,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
/* creates the catalog with the given image */
catalog = malloc(sizeof(struct el_torito_boot_catalog));
if (catalog == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto boot_image_cleanup;
}
catalog->image = boot_image;
@ -657,12 +657,12 @@ int catalog_stream_new(Ecma119Image *target, IsoStream **stream)
str = malloc(sizeof(IsoStream));
if (str == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(struct catalog_stream));
if (str == NULL) {
free(str);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill data */
@ -684,7 +684,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src)
IsoStream *stream;
if (target == NULL || src == NULL || target->catalog == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
if (target->cat != NULL) {
@ -695,7 +695,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src)
file = malloc(sizeof(IsoFileSrc));
if (file == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ret = catalog_stream_new(target, &stream);
@ -825,7 +825,7 @@ int eltorito_writer_write_data(IsoImageWriter *writer)
size = (size_t) iso_stream_get_size(original);
buf = malloc(size);
if (buf == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ret = iso_stream_open(original);
if (ret < 0) {
@ -868,7 +868,7 @@ int eltorito_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = eltorito_writer_compute_data_blocks;

View File

@ -9,56 +9,168 @@
#define LIBISO_ERROR_H_
/*
* Return values for libisofs functions, mainly error codes
* Error codes and return values for libisofs.
* TODO #00003 make this header public
*/
/*
* error codes are 32 bit numbers, that follow the following conventions:
*
* bit 31 (MSB) -> 1 (to make the value always negative)
* bits 30-24 -> Encoded severity (Use ISO_ERR_SEV to translate an error code
* to a LIBISO_MSGS_SEV_* constant)
* = 0x10 -> DEBUG
* = 0x20 -> UPDATE
* = 0x30 -> NOTE
* = 0x40 -> HINT
* = 0x50 -> WARNING
* = 0x60 -> SORRY
* = 0x6A -> ERROR
* = 0x70 -> FATAL
* = 0x71 -> ABORT
* bits 23-20 -> Encoded priority (Use ISO_ERR_PRIO to translate an error code
* to a LIBISO_MSGS_PRIO_* constant)
* = 0x0 -> ZERO
* = 0x1 -> LOW
* = 0x2 -> MEDIUM
* = 0x3 -> HIGH
* = 0x7 -> TOP
* bits 19-16 -> Reserved for future usage (maybe message ranges)
* bits 15-0 -> Error code
*/
#define ISO_ERR_SEV(e) (e & 0x7F000000)
#define ISO_ERR_PRIO(e) ((e & 0x00F00000) << 8)
#define ISO_ERR_CODE(e) (e & 0x0000FFFF)
/** successfully execution */
#define ISO_SUCCESS 1
#define ISO_ERROR -1
#define ISO_NULL_POINTER -2
#define ISO_OUT_OF_MEM -3
#define ISO_MEM_ERROR -4
#define ISO_INTERRUPTED -5
#define ISO_WRONG_ARG_VALUE -6
/* canceled by user */
#define ISO_ABORT -7
/**
* special return value, it could be or not an error depending on the
* context.
*/
#define ISO_NONE 0
#define ISO_WRITE_ERROR -10
#define ISO_THREAD_ERROR -11
/** Operation canceled (ERROR,TOP, -1) */
#define ISO_CANCELED 0xEA70FFFF
#define ISO_NODE_ALREADY_ADDED -50
#define ISO_NODE_NAME_NOT_UNIQUE -51
#define ISO_NODE_NOT_ADDED_TO_DIR -52
/** Unknown or unexpected fatal error (FATAL,HIGH, -2) */
#define ISO_FATAL_ERROR 0xF030FFFE
#define ISO_FILE_ERROR -100
#define ISO_FILE_ALREADY_OPENNED -101
#define ISO_FILE_ACCESS_DENIED -102
#define ISO_FILE_BAD_PATH -103
#define ISO_FILE_DOESNT_EXIST -104
#define ISO_FILE_NOT_OPENNED -105
#define ISO_FILE_IS_DIR -106
#define ISO_FILE_READ_ERROR -107
#define ISO_FILE_IS_NOT_DIR -108
#define ISO_FILE_IS_NOT_SYMLINK -109
#define ISO_FILE_TOO_BIG -110
#define ISO_FILE_SEEK_ERROR -111
/** Unknown or unexpected error (ERROR,HIGH, -3) */
#define ISO_ERROR 0xEA30FFFD
#define ISO_CHARSET_CONV_ERROR -150
/** Internal programming error. Please report this bug (FATAL,HIGH, -4) */
#define ISO_ASSERT_FAILURE 0xF030FFFC
#define ISO_MANGLE_TOO_MUCH_FILES -200
/**
* NULL pointer as value for an arg. that doesn't allow NULL (ERROR,HIGH, -5)
*/
#define ISO_NULL_POINTER 0xEA30FFFB
/* image read errors */
#define ISO_WRONG_PVD -300
#define ISO_WRONG_RR -301
#define ISO_UNSUPPORTED_RR -302
#define ISO_WRONG_ECMA119 -303
#define ISO_UNSUPPORTED_ECMA119 -304
#define ISO_WRONG_EL_TORITO -305
/** Memory allocation error (FATAL,HIGH, -6) */
#define ISO_OUT_OF_MEM 0xF030FFFA
/* el-torito errors */
#define ISO_IMAGE_ALREADY_BOOTABLE -350
#define ISO_BOOT_IMAGE_NOT_VALID -351
/** Interrupted by a signal (FATAL,HIGH, -7) */
#define ISO_INTERRUPTED 0xF030FFF9
/** Invalid parameter value (ERROR,HIGH, -8) */
#define ISO_WRONG_ARG_VALUE 0xF030FFF8
/** Can't create a needed thread (FATAL,HIGH, -9) */
#define ISO_THREAD_ERROR 0xF030FFF7
/** Trying to add to a dir a node already added to a dir (ERROR,HIGH, -64) */
#define ISO_NODE_ALREADY_ADDED 0xEA30FFC0
/** Node with same name already exists (ERROR,HIGH, -65) */
#define ISO_NODE_NAME_NOT_UNIQUE 0xEA30FFBF
/** Trying to remove a node that was not added to dir (ERROR,HIGH, -65) */
#define ISO_NODE_NOT_ADDED_TO_DIR 0xEA30FFBE
/** A requested node does not exists (ERROR,HIGH, -66) */
#define ISO_NODE_DOESNT_EXIST 0xEA30FFBD
/** Try to set the boot image of an already bootable image (ERROR,HIGH, -67) */
#define ISO_IMAGE_ALREADY_BOOTABLE 0xEA30FFBC
/** Trying to use an invalid file as boot image (ERROR,HIGH, -68) */
#define ISO_BOOT_IMAGE_NOT_VALID 0xEA30FFBB
/**
* Error on file operation (ERROR,HIGH, -128)
* (take a look at more specified error codes below)
*/
#define ISO_FILE_ERROR 0xEA30FF80
/** Trying to open an already openned file (ERROR,HIGH, -129) */
#define ISO_FILE_ALREADY_OPENNED 0xEA30FF7F
/** Access to file is not allowed (ERROR,HIGH, -130) */
#define ISO_FILE_ACCESS_DENIED 0xEA30FF7E
/** Incorrect path to file (ERROR,HIGH, -131) */
#define ISO_FILE_BAD_PATH 0xEA30FF7D
/** The file does not exists in the filesystem (ERROR,HIGH, -132) */
#define ISO_FILE_DOESNT_EXIST 0xEA30FF7C
/** Trying to read or close a file not openned (ERROR,HIGH, -133) */
#define ISO_FILE_NOT_OPENNED 0xEA30FF7B
/** Directory used where no dir is expected (ERROR,HIGH, -134) */
#define ISO_FILE_IS_DIR 0xEA30FF7A
/** Read error (ERROR,HIGH, -135) */
#define ISO_FILE_READ_ERROR 0xEA30FF79
/** Not dir used where a dir is expected (ERROR,HIGH, -136) */
#define ISO_FILE_IS_NOT_DIR 0xEA30FF78
/** Not symlink used where a symlink is expected (ERROR,HIGH, -137) */
#define ISO_FILE_IS_NOT_SYMLINK 0xEA30FF77
/** Can't seek to specified location (ERROR,HIGH, -138) */
#define ISO_FILE_SEEK_ERROR 0xEA30FF76
/* will be a NOTE message */
/* #define ISO_FILE_TOO_BIG -139 */
/** Charset conversion error (ERROR,HIGH, -256) */
#define ISO_CHARSET_CONV_ERROR 0xEA30FF00
/**
* Too much files to mangle, i.e. we cannot guarantee unique file names
* (ERROR,HIGH, -257)
*/
#define ISO_MANGLE_TOO_MUCH_FILES 0xEA30FEFF
/* image related errors */
/**
* Wrong or damaged Primary Volume Descriptor (ERROR,HIGH, -320)
* This could mean that the file is not a valid ISO image.
*/
#define ISO_WRONG_PVD 0xEA30FEC0
/** Wrong or damaged RR entry (SORRY,HIGH, -321) */
#define ISO_WRONG_RR 0xE030FEBF
/** Unsupported RR feature (SORRY,HIGH, -322) */
#define ISO_UNSUPPORTED_RR 0xE030FEBE
/** Wrong or damaged ECMA-119 (ERROR,HIGH, -323) */
#define ISO_WRONG_ECMA119 0xEA30FEBD
/** Unsupported ECMA-119 feature (ERROR,HIGH, -324) */
#define ISO_UNSUPPORTED_ECMA119 0xEA30FEBC
/** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */
#define ISO_WRONG_EL_TORITO 0xEA30FEBB
/** Unsupported El-Torito feature (SORRY,HIGH, -326) */
#define ISO_UNSUPPORTED_EL_TORITO 0xEA30FEBA
#endif /*LIBISO_ERROR_H_*/

View File

@ -63,7 +63,7 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
fsrc = malloc(sizeof(IsoFileSrc));
if (fsrc == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill key and other atts */
@ -149,7 +149,7 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
int (*inc_item)(void *);
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -164,7 +164,7 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
/* store the filesrcs in a array */
filelist = (IsoFileSrc**)iso_rbtree_to_array(t->files, inc_item, &size);
if (filelist == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* sort files by weight, if needed */
@ -247,7 +247,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
char buffer[BLOCK_SIZE];
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -344,7 +344,7 @@ int iso_file_src_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = filesrc_writer_compute_data_blocks;

View File

@ -253,7 +253,7 @@ int ifs_stat(IsoFileSource *src, struct stat *info)
data = (ImageFileSourceData*)src->data;
if (S_ISLNK(data->info.st_mode)) {
/* TODO #00012 : support follow symlinks on imafe filesystem */
/* TODO #00012 : support follow symlinks on image filesystem */
return ISO_FILE_BAD_PATH;
}
*info = data->info;
@ -364,7 +364,7 @@ int read_dir(ImageFileSourceData *data)
node = malloc(sizeof(struct child_list));
if (node == NULL) {
iso_file_source_unref(child);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/*
* Note that we insert in reverse order. This leads to faster
@ -429,7 +429,7 @@ int ifs_open(IsoFileSource *src)
}
data->data.content = malloc(BLOCK_SIZE);
if (data->data.content == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
data->data.offset = 0;
data->opened = 1;
@ -492,7 +492,7 @@ int ifs_close(IsoFileSource *src)
* ISO_NULL_POINTER
* ISO_FILE_NOT_OPENNED
* ISO_FILE_IS_DIR
* ISO_MEM_ERROR
* ISO_OUT_OF_MEM
* ISO_INTERRUPTED
*/
static
@ -607,7 +607,7 @@ int ifs_readdir(IsoFileSource *src, IsoFileSource **child)
* ISO_NULL_POINTER
* ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
* ISO_FILE_IS_NOT_SYMLINK
* ISO_MEM_ERROR
* ISO_OUT_OF_MEM
* ISO_FILE_BAD_PATH
* ISO_FILE_DOESNT_EXIST
*
@ -818,7 +818,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
iter = susp_iter_new(fsdata->src, record, fsdata->len_skp,
fsdata->msgid);
if (iter == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
while ((ret = susp_iter_next(iter, &sue)) > 0) {
@ -1123,12 +1123,12 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* ok, we can now create the file source */
ifsdata = calloc(1, sizeof(ImageFileSourceData));
if (ifsdata == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto ifs_cleanup;
}
ifsrc = calloc(1, sizeof(IsoFileSource));
if (ifsrc == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto ifs_cleanup;
}
@ -1268,7 +1268,7 @@ int ifs_get_by_path(IsoFilesystem *fs, const char *path, IsoFileSource **file)
ptr = strdup(path);
if (ptr == NULL) {
iso_file_source_unref(src);
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto get_path_exit;
}
@ -1415,7 +1415,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
iter = susp_iter_new(data->src, record, data->len_skp, data->msgid);
if (iter == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* first entry must be an SP system use entry */
@ -1597,7 +1597,7 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
iso_msg_hint(data->msgid, LIBISO_EL_TORITO_UNHANLED,
"Unsupported El-Torito platform. Only 80x86 is "
"supported. El-Torito info will be ignored.");
return ISO_WRONG_EL_TORITO;
return ISO_UNSUPPORTED_EL_TORITO;
}
/* ok, once we are here we assume it is a valid catalog */
@ -1633,13 +1633,13 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data = calloc(1, sizeof(_ImageFsData));
if (data == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ifs = calloc(1, sizeof(IsoImageFilesystem));
if (ifs == NULL) {
free(data);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* get our ref to IsoDataSource */
@ -1659,7 +1659,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
setlocale(LC_CTYPE, "");
data->local_charset = strdup(nl_langinfo(CODESET));
if (data->local_charset == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto fs_cleanup;
}
@ -1819,7 +1819,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
}
}
if (data->input_charset == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto fs_cleanup;
}
@ -1879,7 +1879,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
* a regular file */
new = calloc(1, sizeof(IsoBoot));
if (new == NULL) {
result = ISO_MEM_ERROR;
result = ISO_OUT_OF_MEM;
free(name);
return result;
}
@ -1904,7 +1904,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
if (file == NULL) {
free(name);
iso_stream_unref(stream);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* the msblock is taken from the image */
@ -1941,7 +1941,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
new = calloc(1, sizeof(IsoDir));
if (new == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
new->type = LIBISO_DIR;
new->refcount = 0;
@ -1961,7 +1961,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
link = malloc(sizeof(IsoSymlink));
if (link == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
link->dest = strdup(dest);
link->node.type = LIBISO_SYMLINK;
@ -1979,7 +1979,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
special = malloc(sizeof(IsoSpecial));
if (special == NULL) {
free(name);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
special->dev = info.st_rdev;
special->node.type = LIBISO_SPECIAL;
@ -2023,7 +2023,7 @@ int iso_image_builder_new(IsoNodeBuilder *old, IsoNodeBuilder **builder)
b = malloc(sizeof(IsoNodeBuilder));
if (b == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
b->refcount = 1;
@ -2077,12 +2077,12 @@ int create_boot_img_filesrc(IsoImageFilesystem *fs, IsoFileSource **src)
/* ok, we can now create the file source */
ifsdata = calloc(1, sizeof(ImageFileSourceData));
if (ifsdata == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto boot_fs_cleanup;
}
ifsrc = calloc(1, sizeof(IsoFileSource));
if (ifsrc == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto boot_fs_cleanup;
}
@ -2178,7 +2178,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
boot_image = calloc(1, sizeof(ElToritoBootImage));
if (boot_image == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto import_revert;
}
boot_image->bootable = data->bootable;
@ -2189,7 +2189,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
catalog = calloc(1, sizeof(struct el_torito_boot_catalog));
if (catalog == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto import_revert;
}
catalog->image = boot_image;
@ -2225,7 +2225,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
if (image->bootcat->node == NULL) {
IsoNode *node = calloc(1, sizeof(IsoBoot));
if (node == NULL) {
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
goto import_revert;
}
node->mode = S_IFREG;

View File

@ -105,7 +105,7 @@ int lfs_lstat(IsoFileSource *src, struct stat *info)
break;
case EFAULT:
case ENOMEM:
err = ISO_MEM_ERROR;
err = ISO_OUT_OF_MEM;
break;
default:
err = ISO_FILE_ERROR;
@ -147,7 +147,7 @@ int lfs_stat(IsoFileSource *src, struct stat *info)
break;
case EFAULT:
case ENOMEM:
err = ISO_MEM_ERROR;
err = ISO_OUT_OF_MEM;
break;
default:
err = ISO_FILE_ERROR;
@ -221,7 +221,7 @@ int lfs_open(IsoFileSource *src)
break;
case EFAULT:
case ENOMEM:
err = ISO_MEM_ERROR;
err = ISO_OUT_OF_MEM;
break;
default:
err = ISO_FILE_ERROR;
@ -286,7 +286,7 @@ int lfs_read(IsoFileSource *src, void *buf, size_t count)
ret = ISO_INTERRUPTED;
break;
case EFAULT:
ret = ISO_MEM_ERROR;
ret = ISO_OUT_OF_MEM;
break;
case EIO:
ret = ISO_FILE_READ_ERROR;
@ -385,7 +385,7 @@ int lfs_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
return ISO_FILE_IS_NOT_SYMLINK;
case EFAULT:
case ENOMEM:
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
default:
return ISO_FILE_ERROR;
}
@ -454,7 +454,7 @@ int iso_file_source_new_lfs(IsoFileSource *parent, const char *name,
if (lfs == NULL) {
/* this should never happen */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
/* allocate memory */
@ -532,7 +532,7 @@ int lfs_get_by_path(IsoFilesystem *fs, const char *path, IsoFileSource **file)
break;
case EFAULT:
case ENOMEM:
err = ISO_MEM_ERROR;
err = ISO_OUT_OF_MEM;
break;
default:
err = ISO_FILE_ERROR;
@ -555,7 +555,7 @@ int lfs_get_by_path(IsoFilesystem *fs, const char *path, IsoFileSource **file)
ptr = strdup(path);
if (ptr == NULL) {
iso_file_source_unref(src);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
component = strtok_r(ptr, "/", &brk_info);

View File

@ -39,14 +39,14 @@ int iso_image_new(const char *name, IsoImage **image)
img = calloc(1, sizeof(IsoImage));
if (img == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* local filesystem will be used by default */
res = iso_local_filesystem_new(&(img->fs));
if (res < 0) {
free(img);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* use basic builder as default */
@ -54,7 +54,7 @@ int iso_image_new(const char *name, IsoImage **image)
if (res < 0) {
iso_filesystem_unref(img->fs);
free(img);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill image fields */

View File

@ -83,7 +83,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, Iso1999Node **node)
n = calloc(1, sizeof(Iso1999Node));
if (n == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
if (iso->type == LIBISO_DIR) {
@ -91,13 +91,13 @@ int create_node(Ecma119Image *t, IsoNode *iso, Iso1999Node **node)
n->info.dir = calloc(1, sizeof(struct iso1999_dir_info));
if (n->info.dir == NULL) {
free(n);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
n->info.dir->children = calloc(sizeof(void*), dir->nchildren);
if (n->info.dir->children == NULL) {
free(n->info.dir);
free(n);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
n->type = ISO1999_DIR;
} else if (iso->type == LIBISO_FILE) {
@ -136,7 +136,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, Iso1999Node **node)
} else {
/* should never happen */
free(n);
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
/* take a ref to the IsoNode */
@ -232,7 +232,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
break;
default:
/* should never happen */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
if (ret <= 0) {
free(iso_name);
@ -289,7 +289,7 @@ int iso1999_tree_create(Ecma119Image *t)
if (ret <= 0) {
if (ret == 0) {
/* unexpected error, root ignored!! This can't happen */
ret = ISO_ERROR;
ret = ISO_ASSERT_FAILURE;
}
return ret;
}
@ -406,7 +406,7 @@ int iso1999_writer_compute_data_blocks(IsoImageWriter *writer)
uint32_t path_table_size;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -504,7 +504,7 @@ int iso1999_writer_write_vol_desc(IsoImageWriter *writer)
char *biblio_file_id = NULL;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -708,7 +708,7 @@ int write_path_tables(Ecma119Image *t)
/* allocate temporal pathlist */
pathlist = malloc(sizeof(void*) * t->iso1999_ndirs);
if (pathlist == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
pathlist[0] = t->iso1999_root;
cur = 1;
@ -776,7 +776,7 @@ int iso1999_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = iso1999_writer_compute_data_blocks;

View File

@ -51,7 +51,7 @@ int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
* only possible if mem error, as check for empty names is done
* in public tree
*/
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
}
@ -87,7 +87,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
joliet = calloc(1, sizeof(JolietNode));
if (joliet == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
if (iso->type == LIBISO_DIR) {
@ -95,13 +95,13 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
joliet->info.dir = calloc(1, sizeof(struct joliet_dir_info));
if (joliet->info.dir == NULL) {
free(joliet);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
joliet->info.dir->children = calloc(sizeof(void*), dir->nchildren);
if (joliet->info.dir->children == NULL) {
free(joliet->info.dir);
free(joliet);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
joliet->type = JOLIET_DIR;
} else if (iso->type == LIBISO_FILE) {
@ -140,7 +140,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
} else {
/* should never happen */
free(joliet);
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
/* take a ref to the IsoNode */
@ -242,7 +242,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
break;
default:
/* should never happen */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
if (ret <= 0) {
free(jname);
@ -289,7 +289,7 @@ int joliet_tree_create(Ecma119Image *t)
if (ret <= 0) {
if (ret == 0) {
/* unexpected error, root ignored!! This can't happen */
ret = ISO_ERROR;
ret = ISO_ASSERT_FAILURE;
}
return ret;
}
@ -409,7 +409,7 @@ int joliet_writer_compute_data_blocks(IsoImageWriter *writer)
uint32_t path_table_size;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -539,7 +539,7 @@ int joliet_writer_write_vol_desc(IsoImageWriter *writer)
uint16_t *biblio_file_id = NULL;
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = writer->target;
@ -747,7 +747,7 @@ int write_path_tables(Ecma119Image *t)
/* allocate temporal pathlist */
pathlist = malloc(sizeof(void*) * t->joliet_ndirs);
if (pathlist == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
pathlist[0] = t->joliet_root;
cur = 1;
@ -815,7 +815,7 @@ int joliet_writer_create(Ecma119Image *target)
writer = malloc(sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
writer->compute_data_blocks = joliet_writer_compute_data_blocks;

View File

@ -145,6 +145,11 @@ struct libiso_msgs_item;
*/
#define LIBISO_MSGS_SEV_SORRY 0x60000000
/** error messages indicating that the operation has failed, but you can
still continue using the library and even retry the operation
*/
#define LIBISO_MSGS_SEV_ERROR 0x6A000000
/** An error message which puts the whole operation of the program in question
*/
#define LIBISO_MSGS_SEV_FATAL 0x70000000
@ -167,7 +172,7 @@ struct libiso_msgs_item;
#define LIBISO_MSGS_PRIO_LOW 0x10000000
#define LIBISO_MSGS_PRIO_MEDIUM 0x20000000
#define LIBISO_MSGS_PRIO_HIGH 0x30000000
#define LIBISO_MSGS_PRIO_TOP 0x7ffffffe
#define LIBISO_MSGS_PRIO_TOP 0x70000000
/* Do not use this priority for submitting */
#define LIBISO_MSGS_PRIO_NEVER 0x7fffffff

View File

@ -24,7 +24,7 @@ int iso_init()
{
if (libiso_msgr == NULL) {
if (libiso_msgs_new(&libiso_msgr, 0) <= 0)
return ISO_ERROR;
return ISO_FATAL_ERROR;
}
libiso_msgs_set_severities(libiso_msgr, LIBISO_MSGS_SEV_NEVER,
LIBISO_MSGS_SEV_FATAL, "libisofs: ", 0);

View File

@ -108,7 +108,7 @@ int iso_node_set_name(IsoNode *node, const char *name)
new = strdup(name);
if (new == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
free(node->name);
node->name = new;
@ -251,7 +251,10 @@ time_t iso_node_get_ctime(const IsoNode *node)
void iso_node_set_hidden(IsoNode *node, int hide_attrs)
{
node->hidden = hide_attrs;
/* you can't hide root node */
if ((IsoNode*)node->parent != node) {
node->hidden = hide_attrs;
}
}
/**
@ -551,7 +554,7 @@ int iso_symlink_set_dest(IsoSymlink *link, const char *dest)
}
d = strdup(dest);
if (d == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
free(link->dest);
link->dest = d;
@ -724,7 +727,7 @@ int iso_node_new_root(IsoDir **root)
dir = calloc(1, sizeof(IsoDir));
if (dir == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
dir->node.refcount = 1;
dir->node.type = LIBISO_DIR;

View File

@ -24,7 +24,7 @@ int susp_append(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
susp->susp_fields = realloc(susp->susp_fields, sizeof(void*)
* susp->n_susp_fields);
if (susp->susp_fields == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
susp->susp_fields[susp->n_susp_fields - 1] = data;
susp->suf_len += data[2];
@ -38,7 +38,7 @@ int susp_append_ce(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
susp->ce_susp_fields = realloc(susp->ce_susp_fields, sizeof(void*)
* susp->n_ce_susp_fields);
if (susp->ce_susp_fields == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
susp->ce_susp_fields[susp->n_ce_susp_fields - 1] = data;
susp->ce_len += data[2];
@ -90,7 +90,7 @@ int rrip_add_PX(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
{
uint8_t *PX = malloc(44);
if (PX == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
PX[0] = 'P';
@ -115,7 +115,7 @@ int rrip_add_TF(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
{
uint8_t *TF = malloc(5 + 3 * 7);
if (TF == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
TF[0] = 'T';
@ -146,12 +146,12 @@ int rrip_add_PL(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
if (n->type != ECMA119_DIR || n->info.dir->real_parent == NULL) {
/* should never occur */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
PL = malloc(12);
if (PL == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
PL[0] = 'P';
@ -178,7 +178,7 @@ int rrip_add_RE(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
{
uint8_t *RE = malloc(4);
if (RE == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
RE[0] = 'R';
@ -204,12 +204,12 @@ int rrip_add_PN(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
node = (IsoSpecial*)n->node;
if (node->node.type != LIBISO_SPECIAL) {
/* should never occur */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
PN = malloc(20);
if (PN == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
PN[0] = 'P';
@ -233,11 +233,11 @@ int rrip_add_CL(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
uint8_t *CL;
if (n->type != ECMA119_PLACEHOLDER) {
/* should never occur */
return ISO_ERROR;
return ISO_ASSERT_FAILURE;
}
CL = malloc(12);
if (CL == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
CL[0] = 'C';
@ -295,7 +295,7 @@ int rrip_add_NM(Ecma119Image *t, struct susp_info *susp, char *name, int size,
{
uint8_t *NM = malloc(size + 5);
if (NM == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
NM[0] = 'N';
@ -334,7 +334,7 @@ int rrip_SL_append_comp(size_t *n, uint8_t ***comps, char *s, int size, char fl)
{
uint8_t *comp = malloc(size + 2);
if (comp == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
(*n)++;
@ -343,7 +343,7 @@ int rrip_SL_append_comp(size_t *n, uint8_t ***comps, char *s, int size, char fl)
*comps = realloc(*comps, (*n) * sizeof(void*));
if (*comps == NULL) {
free(comp);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
(*comps)[(*n) - 1] = comp;
@ -385,7 +385,7 @@ int rrip_add_SL(Ecma119Image *t, struct susp_info *susp, uint8_t **comp,
total_comp_len -= comp[i][1] + 2;
SL = malloc(total_comp_len + 5);
if (SL == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
SL[0] = 'S';
@ -404,7 +404,7 @@ int rrip_add_SL(Ecma119Image *t, struct susp_info *susp, uint8_t **comp,
* debug purposes
*/
if (ce == 0) {
return ISO_ERROR; /* unexpected */
return ISO_ASSERT_FAILURE;
}
ret = susp_append_ce(t, susp, SL);
if (ret < 0) {
@ -417,7 +417,7 @@ int rrip_add_SL(Ecma119Image *t, struct susp_info *susp, uint8_t **comp,
SL = malloc(total_comp_len + 5);
if (SL == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
SL[0] = 'S';
@ -453,7 +453,7 @@ int rrip_add_ER(Ecma119Image *t, struct susp_info *susp)
{
unsigned char *ER = malloc(182);
if (ER == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ER[0] = 'E';
@ -484,7 +484,7 @@ int susp_add_CE(Ecma119Image *t, size_t ce_len, struct susp_info *susp)
{
uint8_t *CE = malloc(28);
if (CE == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
CE[0] = 'C';
@ -508,7 +508,7 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp)
{
unsigned char *SP = malloc(7);
if (SP == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
SP[0] = 'S';

View File

@ -297,7 +297,7 @@ int read_rr_NM(struct susp_sys_user_entry *nm, char **name, int *cont)
*name = strcopy((char*)nm->data.NM.name, nm->len_sue[0] - 5);
}
if (*name == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* and set cond according to the value of CONTINUE flag */
@ -355,7 +355,7 @@ int read_rr_SL(struct susp_sys_user_entry *sl, char **dest, int *cont)
size_t size = strlen(*dest);
*dest = realloc(*dest, strlen(*dest) + len + 2);
if (*dest == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* it is a new compoenent, add the '/' */
if ((*dest)[size-1] != '/') {
@ -367,7 +367,7 @@ int read_rr_SL(struct susp_sys_user_entry *sl, char **dest, int *cont)
/* the component continues */
*dest = realloc(*dest, strlen(*dest) + len + 1);
if (*dest == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* we don't have to add the '/' */
strncat(*dest, comp, len);
@ -375,7 +375,7 @@ int read_rr_SL(struct susp_sys_user_entry *sl, char **dest, int *cont)
*dest = strcopy(comp, len);
}
if (*dest == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* do the component continue or not? */
*cont = (flags & 0x01) ? 2 : 1;

View File

@ -163,12 +163,12 @@ int iso_file_source_stream_new(IsoFileSource *src, IsoStream **stream)
str = malloc(sizeof(IsoStream));
if (str == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(FSrcStreamData));
if (str == NULL) {
free(str);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* take the ref to IsoFileSource */
@ -335,12 +335,12 @@ int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream)
str = malloc(sizeof(IsoStream));
if (str == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(MemStreamData));
if (str == NULL) {
free(str);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* fill data */

View File

@ -70,7 +70,7 @@ int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir)
node = calloc(1, sizeof(IsoDir));
if (node == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->node.refcount = 1;
@ -78,7 +78,7 @@ int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir)
node->node.name = strdup(name);
if (node->node.name == NULL) {
free(node);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* permissions from parent */
@ -123,7 +123,7 @@ int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir)
* Possible errors:
* ISO_NULL_POINTER, if parent, name or dest are NULL
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
* ISO_MEM_ERROR
* ISO_OUT_OF_MEM
*/
int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
const char *dest, IsoSymlink **link)
@ -158,7 +158,7 @@ int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
node = calloc(1, sizeof(IsoSymlink));
if (node == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->node.refcount = 1;
@ -166,14 +166,14 @@ int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
node->node.name = strdup(name);
if (node->node.name == NULL) {
free(node);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->dest = strdup(dest);
if (node->dest == NULL) {
free(node->node.name);
free(node);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/* permissions from parent */
@ -231,7 +231,7 @@ int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
* Possible errors:
* ISO_NULL_POINTER, if parent, name or dest are NULL
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
* ISO_MEM_ERROR
* ISO_OUT_OF_MEM
*
*/
int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
@ -264,7 +264,7 @@ int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
node = calloc(1, sizeof(IsoSpecial));
if (node == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->node.refcount = 1;
@ -272,7 +272,7 @@ int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
node->node.name = strdup(name);
if (node->node.name == NULL) {
free(node);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
node->node.mode = mode;
@ -576,7 +576,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
if (image->recOpts.report) {
int r = image->recOpts.report(file);
if (r <= 0) {
ret = (r < 0 ? ISO_ABORT : ISO_SUCCESS);
ret = (r < 0 ? ISO_CANCELED : ISO_SUCCESS);
goto dir_rec_continue;
}
}
@ -602,7 +602,7 @@ dir_rec_continue:;
iso_file_source_unref(file);
/* TODO check for error severity to decide what to do */
if (ret == ISO_ABORT || (ret < 0 && image->recOpts.stop_on_error)) {
if (ret == ISO_CANCELED || (ret < 0 && image->recOpts.stop_on_error)) {
break;
}
} /* while */

View File

@ -49,7 +49,7 @@ int strconv(const char *str, const char *icharset, const char *ocharset,
outbytes = (inbytes + 1) * MB_LEN_MAX;
out = alloca(outbytes);
if (out == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
conv = iconv_open(ocharset, icharset);
@ -70,7 +70,7 @@ int strconv(const char *str, const char *icharset, const char *ocharset,
*output = malloc(ret - out + 1);
if (*output == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
memcpy(*output, out, ret - out + 1);
return ISO_SUCCESS;
@ -91,7 +91,7 @@ int strnconv(const char *str, const char *icharset, const char *ocharset,
outbytes = (inbytes + 1) * MB_LEN_MAX;
out = alloca(outbytes);
if (out == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
conv = iconv_open(ocharset, icharset);
@ -112,7 +112,7 @@ int strnconv(const char *str, const char *icharset, const char *ocharset,
*output = malloc(ret - out + 1);
if (*output == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
memcpy(*output, out, ret - out + 1);
return ISO_SUCCESS;
@ -151,7 +151,7 @@ int str2wchar(const char *icharset, const char *input, wchar_t **output)
/* we are sure that numchars <= inbytes */
wstr = malloc(outbytes);
if (wstr == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
ret = (char *)wstr;
src = (char *)input;
@ -225,7 +225,7 @@ int str2ascii(const char *icharset, const char *input, char **output)
ret_ = malloc(numchars + 1);
if (ret_ == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
outbytes = numchars;
ret = ret_;
@ -337,7 +337,7 @@ int str2ucs(const char *icharset, const char *input, uint16_t **output)
ret_ = malloc((numchars+1) * sizeof(uint16_t));
if (ret_ == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
outbytes = numchars * sizeof(uint16_t);
ret = ret_;
@ -847,7 +847,7 @@ int str2d_char(const char *icharset, const char *input, char **output)
size_t len, i;
if (output == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/** allow NULL input */
@ -881,7 +881,7 @@ int str2a_char(const char *icharset, const char *input, char **output)
size_t len, i;
if (output == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
/** allow NULL input */
@ -1086,7 +1086,7 @@ int iso_eaccess(const char *path)
break;
case EFAULT:
case ENOMEM:
err = ISO_MEM_ERROR;
err = ISO_OUT_OF_MEM;
break;
default:
err = ISO_FILE_ERROR;

View File

@ -73,7 +73,7 @@ int iso_htable_add(IsoHTable *table, void *key, void *data)
new = iso_hnode_new(key, data);
if (new == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
hash = table->hash(key) % table->cap;
@ -113,7 +113,7 @@ int iso_htable_put(IsoHTable *table, void *key, void *data)
new = iso_hnode_new(key, data);
if (new == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
table->size++;
@ -318,17 +318,17 @@ int iso_htable_create(size_t size, hash_funtion_t hash,
IsoHTable *t;
if (table == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t = malloc(sizeof(IsoHTable));
if (t == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t->table = calloc(size, sizeof(void*));
if (t->table == NULL) {
free(t);
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
t->cap = size;
t->size = 0;

View File

@ -49,7 +49,7 @@ int iso_rbtree_new(int (*compare)(const void*, const void*), IsoRBTree **tree)
}
*tree = calloc(1, sizeof(IsoRBTree));
if (*tree == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
(*tree)->compare = compare;
return ISO_SUCCESS;
@ -154,7 +154,7 @@ int iso_rbtree_insert(IsoRBTree *tree, void *data, void **item)
/* Empty tree case */
tree->root = iso_rbnode_new(data);
if (tree->root == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
new = data;
added = 1;
@ -177,7 +177,7 @@ int iso_rbtree_insert(IsoRBTree *tree, void *data, void **item)
/* Insert new node at the bottom */
p->ch[dir] = q = iso_rbnode_new(data);
if (q == NULL) {
return ISO_MEM_ERROR;
return ISO_OUT_OF_MEM;
}
added = 1;
} else if (is_red(q->ch[0]) && is_red(q->ch[1])) {