~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to tools/corosync-fplay.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Loschwitz
  • Date: 2011-10-19 14:32:18 UTC
  • mfrom: (1.1.6 upstream) (5.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20111019143218-ew8phl0raqyog844
Tags: 1.4.2-1
* Changed my email address in debian/control
* Add corosync-blackbox to the corosync package
* Imported Upstream version 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include <corosync/engine/logsys.h>
20
20
 
21
 
unsigned int flt_data_size;
 
21
uint32_t flt_data_size;
22
22
 
23
 
unsigned int *flt_data;
 
23
uint32_t *flt_data;
24
24
#define FDHEAD_INDEX            (flt_data_size)
25
25
#define FDTAIL_INDEX            (flt_data_size + 1)
26
26
 
341
341
static unsigned int printer_subsys_count =
342
342
  sizeof (printer_subsystems) / sizeof (struct printer_subsys);
343
343
 
344
 
static unsigned int g_record[10000];
 
344
#define G_RECORD_SIZE   10000
 
345
 
 
346
static uint32_t g_record[G_RECORD_SIZE];
345
347
 
346
348
/*
347
349
 * Copy record, dealing with wrapping
348
350
 */
349
351
static int logsys_rec_get (int rec_idx) {
350
 
        unsigned int rec_size;
 
352
        uint32_t rec_size;
351
353
        int firstcopy, secondcopy;
352
354
 
353
355
        rec_size = flt_data[rec_idx];
354
356
 
355
357
        firstcopy = rec_size;
356
358
        secondcopy = 0;
 
359
 
 
360
        if (rec_size > G_RECORD_SIZE || rec_size > flt_data_size) {
 
361
                fprintf (stderr, "rec_size too large. Input file is probably corrupted.\n");
 
362
                exit (EXIT_FAILURE);
 
363
        }
 
364
 
357
365
        if (firstcopy + rec_idx > flt_data_size) {
358
366
                firstcopy = flt_data_size - rec_idx;
359
367
                secondcopy -= firstcopy - rec_size;
360
368
        }
361
 
        memcpy (&g_record[0], &flt_data[rec_idx], firstcopy<<2);
 
369
        memcpy (&g_record[0], &flt_data[rec_idx], firstcopy * sizeof(uint32_t));
362
370
        if (secondcopy) {
363
 
                memcpy (&g_record[firstcopy], &flt_data[0], secondcopy<<2);
 
371
                memcpy (&g_record[firstcopy], &flt_data[0], secondcopy * sizeof(uint32_t));
364
372
        }
365
373
        return ((rec_idx + rec_size) % flt_data_size);
366
374
}
367
375
 
368
376
static void logsys_rec_print (const void *record)
369
377
{
370
 
        const unsigned int *buf_uint32t = record;
371
 
        unsigned int rec_size;
372
 
        unsigned int rec_ident;
373
 
        unsigned int level;
374
 
        unsigned int line;
375
 
        unsigned int arg_size_idx;
 
378
        const uint32_t *buf_uint32t = record;
 
379
        uint32_t rec_size;
 
380
        uint32_t rec_ident;
 
381
        uint32_t level;
 
382
        uint32_t line;
 
383
        uint32_t arg_size_idx;
376
384
        unsigned int i;
377
385
        unsigned int j;
378
386
        unsigned int rec_idx = 0;
379
 
        unsigned int record_number;
 
387
        uint32_t record_number;
380
388
        unsigned int words_processed;
381
389
        unsigned int found;
382
390
        const char *arguments[64];
472
480
                return EXIT_FAILURE;
473
481
        }
474
482
 
475
 
        n_required = sizeof (unsigned int);
 
483
        n_required = sizeof (uint32_t);
476
484
        n_read = read (fd, &flt_data_size, n_required);
477
485
        if (n_read != n_required) {
478
486
                fprintf (stderr, "Unable to read fdata header\n");
479
487
                return EXIT_FAILURE;
480
488
        }
481
489
 
482
 
        n_required = ((flt_data_size + 2) * sizeof(unsigned int));
 
490
        n_required = ((flt_data_size + 2) * sizeof(uint32_t));
483
491
 
484
492
        if ((flt_data = malloc (n_required)) == NULL) {
485
493
                fprintf (stderr, "exhausted virtual memory\n");
494
502
        }
495
503
 
496
504
        if (n_read != n_required) {
497
 
                printf ("Warning: read %lu bytes, but expected %lu\n",
498
 
                        (unsigned long) n_read, (unsigned long) n_required);
 
505
                printf ("Warning: read %zd bytes, but expected %zu\n",
 
506
                        n_read, n_required);
499
507
        }
500
508
 
501
509
        rec_idx = flt_data[FDTAIL_INDEX];