Changes in uspace/app/bdsh/cmds/modules/mkfile/mkfile.c [bc41f3a3:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
rbc41f3a3 r9d58539 27 27 */ 28 28 29 #include <errno.h>30 29 #include <stdio.h> 31 30 #include <stdlib.h> … … 34 33 #include <sys/types.h> 35 34 #include <sys/stat.h> 35 #include <fcntl.h> 36 36 #include <macros.h> 37 37 #include <getopt.h> … … 126 126 argc = cli_count_args(argv); 127 127 128 for (c = 0, opt reset = 1, optind = 0, opt_ind = 0; c != -1;) {128 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 129 129 c = getopt_long(argc, argv, "ps:h", long_options, &opt_ind); 130 130 switch (c) { … … 165 165 const char byte = 0x00; 166 166 167 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) { 168 close(fd); 169 goto error; 170 } 167 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) 168 goto exit; 171 169 172 170 rc2 = write(fd, &byte, sizeof(char)); 173 if (rc2 < 0) { 174 close(fd); 175 goto error; 176 } 177 return CMD_SUCCESS; 171 goto exit; 178 172 } 179 173 … … 189 183 rc = write(fd, buffer, to_write); 190 184 if (rc <= 0) { 191 printf("%s: Error writing file (% d).\n", cmdname, errno);185 printf("%s: Error writing file (%zd).\n", cmdname, rc); 192 186 close(fd); 193 free(buffer);194 187 return CMD_FAILURE; 195 188 } … … 198 191 199 192 free(buffer); 200 201 if (close(fd) < 0) 202 goto error; 193 exit: 194 rc = close(fd); 195 196 if (rc != 0 || rc2 < 0) { 197 printf("%s: Error writing file (%zd).\n", cmdname, rc); 198 return CMD_FAILURE; 199 } 203 200 204 201 return CMD_SUCCESS; 205 error:206 printf("%s: Error writing file (%d).\n", cmdname, errno);207 return CMD_FAILURE;208 202 }
Note:
See TracChangeset
for help on using the changeset viewer.