diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-11-21 06:26:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-11-21 06:26:03 +0000 |
commit | 272c011d197ad04137d6d1d8d5c86ed8b93f61b4 (patch) | |
tree | 3bbebcfa10cec1edddeda5c768754af6046ebb93 /merge.c | |
parent | f2e8579ba375ef960209214fe432afd3bb3f83b1 (diff) |
On an I/O error, merge_read_packet() and merge_append_read_packet() need
to return a pointer to the merge_in_file_t that got the error. Set *err
to 0 on success and an error code on an err, treat a null return as an
EOF indication, and if we don't get a null return check for a non-zero
error code and treat that as an I/O error.
svn path=/trunk/; revision=39964
Diffstat (limited to 'merge.c')
-rw-r--r-- | merge.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -150,9 +150,16 @@ is_earlier(struct wtap_nstime *l, struct wtap_nstime *r) { /* * Read the next packet, in chronological order, from the set of files - * to be merged. Return a pointer to the merge_in_file_t for the file - * from which the packet was read on success, or NULL on EOF or error. - * On EOF, *err is 0; on an error, it's an error code. + * to be merged. + * + * On success, set *err to 0 and return a pointer to the merge_in_file_t + * for the file from which the packet was read. + * + * On a read error, set *err to the error and return a pointer to the + * merge_in_file_t for the file on which we got an error. + * + * On an EOF (meaning all the files are at EOF), set *err to 0 and return + * NULL. */ merge_in_file_t * merge_read_packet(int in_file_count, merge_in_file_t in_files[], @@ -211,9 +218,16 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], /* * Read the next packet, in file sequence order, from the set of files - * to be merged. Return a pointer to the merge_in_file_t for the file - * from which the packet was read on success, or NULL on EOF or error. - * On EOF, *err is 0; on an error, it's an error code. + * to be merged. + * + * On success, set *err to 0 and return a pointer to the merge_in_file_t + * for the file from which the packet was read. + * + * On a read error, set *err to the error and return a pointer to the + * merge_in_file_t for the file on which we got an error. + * + * On an EOF (meaning all the files are at EOF), set *err to 0 and return + * NULL. */ merge_in_file_t * merge_append_read_packet(int in_file_count, merge_in_file_t in_files[], @@ -232,7 +246,7 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[], if (*err != 0) { /* Read error - quit immediately. */ in_files[i].state = GOT_ERROR; - return NULL; + return &in_files[i]; } /* EOF - flag this file as being at EOF, and try the next one. */ in_files[i].state = AT_EOF; @@ -244,5 +258,6 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[], } /* Return the ordinal of the file from which the packet was read. */ + *err = 0; return &in_files[i]; } |