Ticket #2021: 0002-Fixed-problem-with-volatile.patch

File 0002-Fixed-problem-with-volatile.patch, 2.4 KB (added by Ric Claus, on 02/17/12 at 22:03:29)

Fixes problem with volatile usage.

  • cpukit/libmisc/shell/main_mdump.c

    From 11560dc0a685affd607eae0d5b005ba4f003423c Mon Sep 17 00:00:00 2001
    From: Ric Claus <claus@SLAC.Stanford.edu>
    Date: Fri, 17 Feb 2012 13:29:58 -0800
    Subject: [PATCH 2/7] Fixed problem with 'volatile'
    
    ---
     cpukit/libmisc/shell/main_mdump.c |   27 ++++++++++++++++++---------
     1 files changed, 18 insertions(+), 9 deletions(-)
    
    diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
    index 156a6f2..85b690b 100644
    a b  
    1010 *  The license and distribution terms for this file may be
    1111 *  found in the file LICENSE in this distribution or at
    1212 *  http://www.rtems.com/license/LICENSE.
     13 *
     14 *  $Id:$
    1315 */
    1416
    1517#ifdef HAVE_CONFIG_H
    static int args_parse(int argc, char* argv[], void** addr, int* max, int* sz); 
    3133static void mdumpB(void* addr, int m);
    3234static void mdumpW(void* addr, int m);
    3335static void mdumpL(void* addr, int m);
     36static void mdumpC(void* addr, int m);
    3437
    3538int rtems_mdump(void* addr, int max, int sz);
    3639
    int rtems_shell_main_mdump( 
    4346  int   max;
    4447  int   sz;
    4548
    46   if (args_parse(argc, argv, &addr, &max, &sz)) 
     49  if (args_parse(argc, argv, &addr, &max, &sz))
    4750    return -1;
    4851  return rtems_mdump(addr, max, sz);
    4952}
    int args_parse(int argc, 
    114117
    115118int rtems_mdump(void* addr, int max, int sz)
    116119{
    117   unsigned char           n;
    118   unsigned char           m;
    119   volatile unsigned char *pb;
    120   int                     res;
    121   int                     cnt;
     120  unsigned char  m;
     121  unsigned char *pb;
     122  int            res;
     123  int            cnt;
    122124
    123125  if (!((sz == 1) || (sz == 2) || (sz == 4))) {
    124126    printf( "Size argument (%d) is not one of 1 (bytes), "
    int rtems_mdump(void* addr, int max, int sz) 
    147149    if      (sz == 1)  mdumpB(pb, cnt);
    148150    else if (sz == 2)  mdumpW(pb, cnt);
    149151    else if (sz == 4)  mdumpL(pb, cnt);
    150     for (n=0;n<=cnt;n++) {
    151       printf("%c", isprint(pb[n]) ? pb[n] : '.');
    152     }
     152    mdumpC(pb, cnt);
    153153    printf("\n");
    154154    pb += 16;
    155155  }
    void mdumpL(void* addr, int m) 
    191191}
    192192
    193193
     194void mdumpC(void* addr, int m)
     195{
     196  volatile unsigned char* pb = addr;
     197  int n;
     198  for (n=0;n<=m;n++)
     199    printf("%c", isprint(pb[n]) ? pb[n] : '.');
     200}
     201
     202
    194203rtems_shell_cmd_t rtems_shell_MDUMP_Command = {
    195204  "mdump",                                      /* name */
    196205  "mdump [address [length [size]]]",            /* usage */