Ignore:
Timestamp:
01/15/19 16:46:02 (22 months ago)
Author:
Shane Alcock <salcock@…>
Branches:
develop
Children:
edd0448
Parents:
be1b03a
Message:

Fix bad global variable names in examples

The global names were clashing with names used for function
parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/parallel/network_capture.c

    r10553bf r0f5d4de  
    2121#include <string.h>
    2222
    23 static char *output = NULL;
     23static char *outputfile = NULL;
    2424
    2525static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
    2626static int count = 0;
    27 static libtrace_t *trace = NULL;
     27static libtrace_t *inptrace = NULL;
    2828
    2929static int compress_level=-1;
     
    3232static void stop(int signal UNUSED)
    3333{
    34         if (trace)
    35                 trace_pstop(trace);
     34        if (inptrace)
     35                trace_pstop(inptrace);
    3636}
    3737
     
    5757        const char * first_extension = NULL;
    5858
    59         file_index = strrchr(output, '/');
     59        file_index = strrchr(outputfile, '/');
    6060        if (file_index)
    6161                first_extension = strchr(file_index, '.');
     
    6464
    6565        if (first_extension) {
    66                 snprintf(name, sizeof(name), "%.*s-%d%s", (int) (first_extension - output), output, my_id, first_extension);
     66                snprintf(name, sizeof(name), "%.*s-%d%s", (int) (first_extension - outputfile), outputfile, my_id, first_extension);
    6767        } else {
    68                 snprintf(name, sizeof(name), "%s-%d", output, my_id);
     68                snprintf(name, sizeof(name), "%s-%d", outputfile, my_id);
    6969        }
    7070
     
    232232                return 1;
    233233        }
    234         trace = trace_create(argv[optind]);
    235         output = argv[optind+1];
    236 
    237         if (trace_is_err(trace)) {
    238                 trace_perror(trace,"Opening trace file");
     234        inptrace = trace_create(argv[optind]);
     235        outputfile = argv[optind+1];
     236
     237        if (trace_is_err(inptrace)) {
     238                trace_perror(inptrace,"Opening trace file");
    239239                return 1;
    240240        }
     
    247247
    248248        if (snaplen != -1)
    249                 trace_set_snaplen(trace, snaplen);
     249                trace_set_snaplen(inptrace, snaplen);
    250250        if(nb_threads != -1)
    251                 trace_set_perpkt_threads(trace, nb_threads);
     251                trace_set_perpkt_threads(inptrace, nb_threads);
    252252
    253253        /* We use a new version of trace_start(), trace_pstart()
    254254         * The reporter function argument is optional and can be NULL */
    255         if (trace_pstart(trace, NULL, processing, NULL)) {
    256                 trace_perror(trace,"Starting trace");
    257                 trace_destroy(trace);
     255        if (trace_pstart(inptrace, NULL, processing, NULL)) {
     256                trace_perror(inptrace,"Starting trace");
     257                trace_destroy(inptrace);
    258258                trace_destroy_callback_set(processing);
    259259                return 1;
     
    261261
    262262        /* Wait for the trace to finish */
    263         trace_join(trace);
    264 
    265         if (trace_is_err(trace)) {
    266                 trace_perror(trace,"Reading packets");
    267                 trace_destroy(trace);
     263        trace_join(inptrace);
     264
     265        if (trace_is_err(inptrace)) {
     266                trace_perror(inptrace,"Reading packets");
     267                trace_destroy(inptrace);
    268268                trace_destroy_callback_set(processing);
    269269                return 1;
     
    271271
    272272        /* Print stats before we destroy the trace */
    273         stats = trace_get_statistics(trace, NULL);
     273        stats = trace_get_statistics(inptrace, NULL);
    274274        fprintf(stderr, "Overall statistics\n");
    275275        trace_print_statistics(stats, stderr, "\t%s: %"PRIu64"\n");
    276276
    277277        trace_destroy_callback_set(processing);
    278         trace_destroy(trace);
     278        trace_destroy(inptrace);
    279279        return 0;
    280280}
Note: See TracChangeset for help on using the changeset viewer.