Changeset c47e1a8 in mainline for uspace/lib/drv/generic/driver.c
- Timestamp:
- 2010-05-21T07:50:04Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d51ee2b
- Parents:
- cf8cc36 (diff), 15b592b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
rcf8cc36 rc47e1a8 45 45 #include <fibril_synch.h> 46 46 #include <stdlib.h> 47 #include <str ing.h>47 #include <str.h> 48 48 #include <ctype.h> 49 49 #include <errno.h> … … 87 87 (*ctx->handler)(ctx->dev, iid, icall); 88 88 } 89 } 90 91 /** Wrapper for receiving strings 92 * 93 * This wrapper only makes it more comfortable to use async_data_write_* 94 * functions to receive strings. 95 * 96 * @param str Pointer to string pointer (which should be later disposed 97 * by free()). If the operation fails, the pointer is not 98 * touched. 99 * @param max_size Maximum size (in bytes) of the string to receive. 0 means 100 * no limit. 101 * @param received If not NULL, the size of the received data is stored here. 102 * 103 * @return Zero on success or a value from @ref errno.h on failure. 104 * 105 */ 106 static int async_string_receive(char **str, const size_t max_size, size_t *received) 107 { 108 ipc_callid_t callid; 109 size_t size; 110 if (!async_data_write_receive(&callid, &size)) { 111 ipc_answer_0(callid, EINVAL); 112 return EINVAL; 113 } 114 115 if ((max_size > 0) && (size > max_size)) { 116 ipc_answer_0(callid, EINVAL); 117 return EINVAL; 118 } 119 120 char *data = (char *) malloc(size + 1); 121 if (data == NULL) { 122 ipc_answer_0(callid, ENOMEM); 123 return ENOMEM; 124 } 125 126 int rc = async_data_write_finalize(callid, data, size); 127 if (rc != EOK) { 128 free(data); 129 return rc; 130 } 131 132 data[size] = 0; 133 *str = data; 134 if (received != NULL) 135 *received = size; 136 137 return EOK; 89 138 } 90 139
Note:
See TracChangeset
for help on using the changeset viewer.