summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Richter 2010-06-05 16:55:55 +0200
committerGravatar Stefan Richter 2010-09-07 11:26:55 +0200
commit8af54fd97d43de388b687115f4ca5e6645c3777e (patch)
tree12aad7e3ef721779347141bf6c136661d4102671
parenttools/testlibraw: Fix a harmless format string bug (diff)
tools/dumpiso: Add write() return code checks, fix harmless format string bug
Addresses a few compiler warnings about unused results and format string mismatch. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--tools/dumpiso.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/dumpiso.c b/tools/dumpiso.c
index 02d84c0..d4b2c1b 100644
--- a/tools/dumpiso.c
+++ b/tools/dumpiso.c
@@ -163,13 +163,12 @@ void open_dumpfile()
return;
}
- file = open(filename, O_CREAT | O_WRONLY, 0666);
+ file = creat(filename, 0666);
if (file < 0) {
perror("dumpfile open");
exit(1);
}
-
- ftruncate(file, 0);
+
write_header();
}
@@ -180,18 +179,21 @@ iso_handler(raw1394handle_t handle, unsigned char *data,
unsigned int dropped)
{
int ret;
+ unsigned char pad = 0;
static unsigned int counter = 0;
if (++counter % 1000 == 0)
fprintf(stderr, "\r%uK packets", counter/1000);
/* write header */
- write(file, &length, sizeof(length));
- write(file, &channel, sizeof(channel));
- write(file, &tag, sizeof(tag));
- write(file, &sy, sizeof(sy));
- sy = 0;
- write(file, &sy, sizeof(sy));
+ if (write(file, &length, sizeof(length)) != sizeof(length) ||
+ write(file, &channel, sizeof(channel)) != sizeof(channel) ||
+ write(file, &tag, sizeof(tag)) != sizeof(tag) ||
+ write(file, &sy, sizeof(sy)) != sizeof(sy) ||
+ write(file, &pad, sizeof(pad)) != sizeof(pad)) {
+ perror("data write");
+ return RAW1394_ISO_ERROR;
+ }
while (length) {
ret = write(file, data, length);
@@ -215,7 +217,7 @@ int main(int argc, char **argv)
parse_args(argc, argv);
fprintf(stderr, "port: %ld\nchannels: %#016llx\nfile: %s\n", which_port,
- listen_channels, filename);
+ (long long unsigned)listen_channels, filename);
handle = raw1394_new_handle();
if (!handle) {
0fadc3a2700b0e16f&follow=1'>DTO to DTDGravatar John Cowan 1-55/+52 2021-07-26typoGravatar John Cowan 1-1/+1 2021-07-26switching to explicit dtosGravatar John Cowan 1-88/+102 2021-07-26errorsGravatar John Cowan 1-1/+4 2021-07-26more MN-W reviewGravatar John Cowan 1-5/+5 2021-07-26update preview linkGravatar John Cowan 1-1/+1 2021-07-26MN-W reviewGravatar John Cowan 1-6/+6 2021-07-26paired mutatorsGravatar John Cowan 1-43/+68 2021-07-25exceptionsGravatar John Cowan 1-1/+15 2021-07-25new exampleGravatar John Cowan 1-1/+4 2021-07-25updatesGravatar John Cowan 1-2/+4 2021-07-24dtd always first argumentGravatar John Cowan 1-9/+9 2021-07-23DTO to DTDGravatar John Cowan 1-55/+52 2021-07-22typoGravatar John Cowan 1-1/+1 2021-07-22switching to explicit dtosGravatar John Cowan 1-88/+102 2021-07-22errorsGravatar John Cowan 1-1/+4 2021-07-22more MN-W reviewGravatar John Cowan 1-5/+5 2021-07-20update preview linkGravatar John Cowan 1-1/+1 2021-07-20MN-W reviewGravatar John Cowan 1-6/+6 2021-07-18Fix typo.Gravatar Arthur A. Gleckler 2-4/+4 2021-07-18Add <p> around abstract.Gravatar Arthur A. Gleckler 1-2/+2 2021-07-18Publish first draft.draft-1Gravatar Arthur A. Gleckler 3-0/+114 2021-07-18Ignore trailing whitespace.Gravatar Arthur A. Gleckler 11-129/+129 2021-07-18Ignore "Dictionaries.log".Gravatar Arthur A. Gleckler 1-1/+2 2021-07-18Fix errors reported by W3C HTML Validator.Gravatar Arthur A. Gleckler 1-27/+27 2021-07-18Eliminate unnecessary redirect by using TLS/SSL.Gravatar Arthur A. Gleckler 1-1/+1