source: rtems/cpukit/libmisc/shell/main_mfill.c @ 33c82dd

4.11
Last change on this file since 33c82dd was 33c82dd, checked in by Jonathan Brandmeyer <jbrandmeyer@…>, on 03/13/19 at 03:04:27

shell: Correct argument order of mfill

Close #3722.

(cherry picked from commit 2e8a66d13f04015c0024a084578f720ceb15ea00)

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  MFILL Shell Command Implmentation
3 *
4 *  Author: Fernando RUIZ CASAS
5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <ctype.h>
18#include <stdio.h>
19#include <string.h>
20
21#include <rtems.h>
22#include <rtems/shell.h>
23#include <rtems/stringto.h>
24#include "internal.h"
25
26static int rtems_shell_main_mfill(
27  int   argc,
28  char *argv[]
29)
30{
31  unsigned long  tmp;
32  void          *addr;
33  size_t         size;
34  unsigned char  value;
35
36  if ( argc != 4 ) {
37    fprintf(stderr,"%s: too few arguments\n", argv[0]);
38    return -1;
39  }
40
41  /*
42   *  Convert arguments into numbers
43   */
44  if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
45    printf( "Address argument (%s) is not a number\n", argv[1] );
46    return -1;
47  }
48
49  if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
50    printf( "Size argument (%s) is not a number\n", argv[2] );
51    return -1;
52  }
53  size = (size_t) tmp;
54
55  if ( rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
56    printf( "Value argument (%s) is not a number\n", argv[3] );
57    return -1;
58  }
59
60  /*
61   *  Now fill the memory.
62   */
63  memset(addr, value, size);
64
65  return 0;
66}
67
68rtems_shell_cmd_t rtems_shell_MFILL_Command = {
69  "mfill",                                      /* name */
70  "mfill address size value",                   /* usage */
71  "mem",                                        /* topic */
72  rtems_shell_main_mfill,                       /* command */
73  NULL,                                         /* alias */
74  NULL                                          /* next */
75};
Note: See TracBrowser for help on using the repository browser.