Changeset 37e4025 in mainline
- Timestamp:
- 2011-11-04T22:22:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99a1a56
- Parents:
- 2179cf95
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/recognise.c
r2179cf95 r37e4025 66 66 #define BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a)) 67 67 68 /* FIXME: make this dynamic */69 #define MATCH_STRING_MAX 25670 71 68 /** Add formatted match id. 72 69 * … … 77 74 */ 78 75 static int usb_add_match_id(match_id_list_t *matches, int score, 79 const char * format, ...)76 const char *match_str) 80 77 { 81 char *match_str = NULL; 82 match_id_t *match_id = NULL; 83 int rc; 84 85 match_str = malloc(MATCH_STRING_MAX + 1); 86 if (match_str == NULL) { 87 rc = ENOMEM; 88 goto failure; 89 } 90 91 /* 92 * FIXME: replace with dynamic allocation of exact size 93 */ 94 va_list args; 95 va_start(args, format ); 96 vsnprintf(match_str, MATCH_STRING_MAX, format, args); 97 match_str[MATCH_STRING_MAX] = 0; 98 va_end(args); 99 100 match_id = create_match_id(); 78 assert(matches); 79 80 match_id_t *match_id = create_match_id(); 101 81 if (match_id == NULL) { 102 rc = ENOMEM; 103 goto failure; 82 return ENOMEM; 104 83 } 105 84 … … 109 88 110 89 return EOK; 111 112 failure:113 if (match_str != NULL) {114 free(match_str);115 }116 if (match_id != NULL) {117 match_id->id = NULL;118 delete_match_id(match_id);119 }120 121 return rc;122 90 } 123 91 … … 131 99 #define ADD_MATCHID_OR_RETURN(match_ids, score, format, ...) \ 132 100 do { \ 133 int __rc = usb_add_match_id((match_ids), (score), \ 134 format, ##__VA_ARGS__); \ 101 char *str = NULL; \ 102 int __rc = asprintf(&str, format, ##__VA_ARGS__); \ 103 if (__rc > 0) { \ 104 __rc = usb_add_match_id((match_ids), (score), str); \ 105 } \ 135 106 if (__rc != EOK) { \ 107 free(str); \ 136 108 return __rc; \ 137 109 } \ … … 152 124 match_id_list_t *matches) 153 125 { 154 if (desc_interface == NULL) { 155 return EINVAL; 156 } 157 if (matches == NULL) { 126 if (desc_interface == NULL || matches == NULL) { 158 127 return EINVAL; 159 128 }
Note:
See TracChangeset
for help on using the changeset viewer.