Changeset c0393db in mainline
- Timestamp:
- 2015-04-04T21:14:22Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6efd162
- Parents:
- 43523b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
r43523b1 rc0393db 245 245 bool opened = false; 246 246 int fd; 247 size_t len = 0; 247 size_t file_len; 248 size_t total_read = 0; 249 ssize_t r; 248 250 249 251 fd = open(conf_path, O_RDONLY); … … 255 257 opened = true; 256 258 257 len = lseek(fd, 0, SEEK_END);259 file_len = lseek(fd, 0, SEEK_END); 258 260 lseek(fd, 0, SEEK_SET); 259 if ( len == 0) {261 if (file_len == 0) { 260 262 ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.", 261 263 conf_path); … … 263 265 } 264 266 265 buf = malloc( len + 1);267 buf = malloc(file_len + 1); 266 268 if (buf == NULL) { 267 269 ddf_msg(LVL_ERROR, "Memory allocation failed."); … … 269 271 } 270 272 271 if (0 >= read(fd, buf, len)) { 272 ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path); 273 goto cleanup; 274 } 275 276 buf[len] = 0; 273 do { 274 r = read(fd, &buf[total_read], file_len - total_read); 275 if (r < 0) { 276 ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path); 277 goto cleanup; 278 } 279 280 total_read += r; 281 } while (total_read < file_len); 282 283 buf[file_len] = 0; 277 284 278 285 suc = true;
Note:
See TracChangeset
for help on using the changeset viewer.