Changeset 01818c6 for lib/format_rt.c


Ignore:
Timestamp:
09/22/06 14:00:36 (15 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
bed8c66
Parents:
52c7cda
Message:

Fixed warnings in format_rt
Stopped mallocing memory for a rt header read as the pointer will be changed to point into the rt buffer anyway

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_rt.c

    rbad6a93 r01818c6  
    242242                return -1;
    243243        }
     244        RT_INFO->rt_hdr.type = RT_LAST;
    244245
    245246        return 0;
     
    288289static int rt_read(libtrace_t *libtrace, void **buffer, size_t len, int block) {
    289290        int numbytes;
    290         rt_header_t *test_hdr;
    291291       
    292292        assert(len <= RT_BUF_SIZE);
     
    486486static int rt_read_packet_versatile(libtrace_t *libtrace,
    487487                libtrace_packet_t *packet,int blocking) {
    488         static rt_header_t *pkt_hdr = 0;
    489        
    490         if (pkt_hdr == 0) {
    491                 /* first time through */
    492                 pkt_hdr = malloc(sizeof(rt_header_t));
    493                 RT_INFO->rt_hdr.type = RT_LAST;
    494         }
    495 
    496         /*
    497         if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) {
    498                 packet->buf_control = TRACE_CTRL_PACKET;
    499                 packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE);
    500         }
    501         */
     488        rt_header_t *pkt_hdr = NULL;
     489        void *void_hdr;
     490       
    502491        if (packet->buf_control == TRACE_CTRL_PACKET) {
    503492                packet->buf_control = TRACE_CTRL_EXTERNAL;
     
    509498         * rt header - I know it's hax and maybe I'll fix it later on */
    510499        if (RT_INFO->rt_hdr.type == RT_LAST) {
    511        
     500                void_hdr = (void *)pkt_hdr;
     501               
    512502                /* FIXME: Better error handling required */
    513                 if (rt_read(libtrace, (void **)&pkt_hdr,
     503                if (rt_read(libtrace, &void_hdr,
    514504                                sizeof(rt_header_t),blocking) !=
    515505                                sizeof(rt_header_t)) {
    516506                        return -1;
    517507                }
    518 
     508                pkt_hdr = (rt_header_t *)void_hdr;
     509               
    519510                /* Need to salvage these in case the next rt_read overwrites
    520511                 * the buffer they came from! */
Note: See TracChangeset for help on using the changeset viewer.