diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-23 11:33:22 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:31:31 +0200 |
commit | 2f30d52e2753c4fc854753ee2d0efb895a317c9f (patch) | |
tree | fc8704aadad47a0373258e80a25cf8773110547e /procfs.h | |
parent | 0277bc261796743148769a3f76f9cae51c61e0a4 (diff) |
Detect asprintf's ENOMEM in procfs.c rather than everywhere
* procfs.h: Make CONTENTS_LEN an ssize_t rather than a size_t,
and document the change.
* procfs.c (procfs_get_contents): Initialize CONTENTS_LEN to a
negative value, and fail with ENOMEM if it's still negative after the
callback returns. (everywhere): Update to ssize_t.
* dircat.c, netfs.c, process.c,
procfs_dir.c, proclist.c, rootdir.c: Update to
ssize_t and the new GET_CONTENTS semantics.
Diffstat (limited to 'procfs.h')
-rw-r--r-- | procfs.h | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -16,9 +16,11 @@ struct procfs_node_ops symlink or directory, as determined by the file mode in netnode->nn_stat. For regular files and symlinks, they are what you would expect; for directories, they are an argz vector of the - names of the entries. */ - error_t (*get_contents) (void *hook, char **contents, size_t *contents_len); - void (*cleanup_contents) (void *hook, char *contents, size_t contents_len); + names of the entries. If upon return, *CONTENTS_LEN is negative or + unchanged, the call is considered to have failed because of a memory + allocation error. */ + error_t (*get_contents) (void *hook, char **contents, ssize_t *contents_len); + void (*cleanup_contents) (void *hook, char *contents, ssize_t contents_len); /* Lookup NAME in this directory, and store the result in *np. The returned node should be created by lookup() using procfs_make_node() @@ -41,8 +43,8 @@ struct procfs_node_ops }; /* These helper functions can be used as procfs_node_ops.cleanup_contents. */ -void procfs_cleanup_contents_with_free (void *, char *, size_t); -void procfs_cleanup_contents_with_vm_deallocate (void *, char *, size_t); +void procfs_cleanup_contents_with_free (void *, char *, ssize_t); +void procfs_cleanup_contents_with_vm_deallocate (void *, char *, ssize_t); /* Create a new node and return it. Returns NULL if it fails to allocate enough memory. In this case, ops->cleanup will be invoked. */ @@ -69,7 +71,7 @@ void procfs_node_chtype (struct node *np, mode_t type); corresponding child nodes. */ ino64_t procfs_make_ino (struct node *np, const char *filename); -error_t procfs_get_contents (struct node *np, char **data, size_t *data_len); +error_t procfs_get_contents (struct node *np, char **data, ssize_t *data_len); error_t procfs_lookup (struct node *np, const char *name, struct node **npp); void procfs_cleanup (struct node *np); |