Changeset c9f3b45c in mainline
- Timestamp:
- 2010-05-27T15:16:49Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 692c40cb
- Parents:
- 957cfa58
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r957cfa58 rc9f3b45c 89 89 } 90 90 91 /** Wrapper for receiving strings92 *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 disposed97 * by free()). If the operation fails, the pointer is not98 * touched.99 * @param max_size Maximum size (in bytes) of the string to receive. 0 means100 * 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;138 }139 140 91 int register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler, irq_code_t *pseudocode) 141 92 { … … 213 164 dev->handle = dev_handle; 214 165 215 async_ string_receive(&dev_name, 0, NULL);166 async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0); 216 167 dev->name = dev_name; 217 168 -
uspace/srv/devman/main.c
r957cfa58 rc9f3b45c 61 61 static dev_tree_t device_tree; 62 62 63 /** Wrapper for receiving strings64 *65 * This wrapper only makes it more comfortable to use async_data_write_*66 * functions to receive strings.67 *68 * @param str Pointer to string pointer (which should be later disposed69 * by free()). If the operation fails, the pointer is not70 * touched.71 * @param max_size Maximum size (in bytes) of the string to receive. 0 means72 * no limit.73 * @param received If not NULL, the size of the received data is stored here.74 *75 * @return Zero on success or a value from @ref errno.h on failure.76 *77 */78 static int async_string_receive(char **str, const size_t max_size, size_t *received)79 {80 ipc_callid_t callid;81 size_t size;82 if (!async_data_write_receive(&callid, &size)) {83 ipc_answer_0(callid, EINVAL);84 return EINVAL;85 }86 87 if ((max_size > 0) && (size > max_size)) {88 ipc_answer_0(callid, EINVAL);89 return EINVAL;90 }91 92 char *data = (char *) malloc(size + 1);93 if (data == NULL) {94 ipc_answer_0(callid, ENOMEM);95 return ENOMEM;96 }97 98 int rc = async_data_write_finalize(callid, data, size);99 if (rc != EOK) {100 free(data);101 return rc;102 }103 104 data[size] = 0;105 *str = data;106 if (received != NULL)107 *received = size;108 109 return EOK;110 }111 63 112 64 /** … … 129 81 130 82 // Get driver name 131 int rc = async_ string_receive(&drv_name, DEVMAN_NAME_MAXLEN, NULL);83 int rc = async_data_write_accept((void **)&drv_name, true, 0, 0, 0, 0); 132 84 if (rc != EOK) { 133 85 ipc_answer_0(iid, rc); … … 205 157 206 158 char *match_id_str; 207 rc = async_ string_receive(&match_id_str, DEVMAN_NAME_MAXLEN, NULL);159 rc = async_data_write_accept((void **)&match_id_str, true, 0, 0, 0, 0); 208 160 match_id->id = match_id_str; 209 161 if (EOK != rc) { … … 262 214 263 215 char *dev_name = NULL; 264 int rc = async_ string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);216 int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0); 265 217 if (EOK != rc) { 266 218 fibril_rwlock_write_unlock(&tree->rwlock); … … 354 306 static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall) 355 307 { 356 char *pathname; 357 358 /* Get fqdn */ 359 int rc = async_string_receive(&pathname, 0, NULL); 308 char *pathname; 309 int rc = async_data_write_accept((void **)&pathname, true, 0, 0, 0, 0); 360 310 if (rc != EOK) { 361 311 ipc_answer_0(iid, rc);
Note:
See TracChangeset
for help on using the changeset viewer.