Changeset 2193905 for lib/format_erf.c


Ignore:
Timestamp:
11/29/18 10:12:59 (2 years ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
fdf23b8
Parents:
d74ca03
Message:

Apply changes required for pull request #81

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    rf6f3ae5 r2193905  
    3535#include "wandio.h"
    3636
    37 #include <assert.h>
    3837#include <errno.h>
    3938#include <fcntl.h>
     
    180179                        exthdr ++;
    181180                        firstbyte = (uint8_t *)exthdr;
    182                         /*assert(extsize <= ntohs(erfptr->rlen));*/
    183181                        if (extsize > ntohs(erfptr->rlen)) {
    184182                                trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Extension size is greater than dag record record length in erf_get_framing_length()");
     
    233231
    234232        if (!libtrace->format_data) {
    235                 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory erf_init_input()");
     233                trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     234                        "format data inside erf_init_input()");
    236235                return -1;
    237236        }
     
    388387                        break;
    389388                case INDEX_UNKNOWN:
    390                         /*assert(0);*/
    391389                        trace_set_err(libtrace, TRACE_ERR_SEEK_ERF, "Cannot seek to erf timestamp with unknown index in erf_seek_erf()");
    392390                        return -1;
     
    412410
    413411        if (!libtrace->format_data) {
    414                 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory erf_init_output()");
     412                trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     413                        "format data inside erf_init_output()");
    415414                return -1;
    416415        }
     
    475474        } else
    476475                packet->buf_control = TRACE_CTRL_EXTERNAL;
    477        
    478        
     476
    479477        packet->type = rt_type;
    480478        packet->buffer = buffer;
     
    487485        }
    488486
    489         /*assert(erfptr->rlen != 0);*/
    490487        if (erfptr->rlen == 0) {
    491                 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Packet is empty in erf_prepare_packet()\n");
     488                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "ERF packet has an invalid record "
     489                        "length: zero, in erf_prepare_packet()\n");
    492490                return -1;
    493491        }
     
    668666        void *payload = packet->payload;
    669667
    670         /*assert(OUTPUT->file);*/
    671668        if (!OUTPUT->file) {
    672                 trace_set_err_out(libtrace, TRACE_ERR_BAD_IO, "Call init_output before write_packet() in erf_write_packet()");
     669                trace_set_err_out(libtrace, TRACE_ERR_BAD_IO, "Attempted to write ERF packets to a "
     670                        "closed file, must call trace_create_output() before calling trace_write_output()");
    673671                return -1;
    674672        }
     
    722720
    723721                /* Packet length (rlen includes format overhead) */
    724                 /*assert(trace_get_capture_length(packet)>0
    725                                 && trace_get_capture_length(packet)<=65536);*/
    726                 if (!(trace_get_capture_length(packet) > 0
    727                         && trace_get_capture_length(packet) <= 65536)) {
     722                if (trace_get_capture_length(packet) <= 0
     723                        || trace_get_capture_length(packet) > 65536) {
    728724                        trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET,
    729725                                "Capture length is out of range in erf_write_packet()");
    730726                        return -1;
    731727                }
    732                 /*assert(trace_get_framing_length(packet)<=65536);*/
    733728                if (trace_get_framing_length(packet) > 65536) {
    734729                        trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET,
     
    743738
    744739                rlen = trace_get_capture_length(packet) + framing;
    745                 /*assert(rlen > 0 && rlen <= 65536);*/
    746                 if (!(rlen > 0 && rlen <= 65536)) {
     740                if (rlen <= 0 || rlen > 65536) {
    747741                        trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET,
    748742                                "Capture + framing length is out of range in erf_write_packet()");
     
    836830        uint16_t wlen;
    837831
    838         /*assert(packet);*/
    839832        if (!packet) {
    840833                fprintf(stderr, "NULL packet passed to erf_set_capture_length()\n");
Note: See TracChangeset for help on using the changeset viewer.