Changeset c47e1a8 in mainline for uspace/srv/devman/main.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 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.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 <dirent.h> 49 49 #include <fcntl.h> … … 60 60 static driver_list_t drivers_list; 61 61 static dev_tree_t device_tree; 62 63 /** Wrapper for receiving strings 64 * 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 disposed 69 * by free()). If the operation fails, the pointer is not 70 * touched. 71 * @param max_size Maximum size (in bytes) of the string to receive. 0 means 72 * 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 } 62 111 63 112 /** … … 155 204 match_id->score = IPC_GET_ARG1(call); 156 205 157 rc = async_string_receive(&match_id->id, DEVMAN_NAME_MAXLEN, NULL); 206 char *match_id_str; 207 rc = async_string_receive(&match_id_str, DEVMAN_NAME_MAXLEN, NULL); 208 match_id->id = match_id_str; 158 209 if (EOK != rc) { 159 210 delete_match_id(match_id);
Note:
See TracChangeset
for help on using the changeset viewer.