[RTEMS Project] #4556: rtems_shell_main_mmove problem

RTEMS trac trac at rtems.org
Thu Dec 2 14:03:20 UTC 2021


#4556: rtems_shell_main_mmove problem
----------------------------+--------------------
  Reporter:  chenjin_zhong  |      Owner:  (none)
      Type:  defect         |     Status:  new
  Priority:  normal         |  Milestone:  5.1
 Component:  shell          |    Version:  5
  Severity:  normal         |   Keywords:
Blocked By:                 |   Blocking:
----------------------------+--------------------
 Hi, I think **mmove** command in shell means that the memory can be
 overlapped when copy happens. but I find that when implementing this
 function, the **memcpy** is used in RTEMS4.13/RTEMS5.1.Should the
 **memcpy** be replaced with **memmove** ? The src code is listed as
 follows.
 static int rtems_shell_main_mmove(
   int   argc,
   char *argv[]
 )
 {
   unsigned long  tmp;
   void          *src;
   void          *dst;
   size_t         length;

   if ( argc < 4 ) {
     fprintf(stderr,"%s: too few arguments\n", argv[0]);
     return -1;
    }

   /*
    *  Convert arguments into numbers
    */
   if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) {
     printf( "Destination argument (%s) is not a number\n", argv[1] );
     return -1;
   }

   if ( rtems_string_to_pointer(argv[2], &src, NULL) ) {
     printf( "Source argument (%s) is not a number\n", argv[2] );
     return -1;
   }

   if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
     printf( "Length argument (%s) is not a number\n", argv[3] );
     return -1;
   }
   length = (size_t) tmp;

   /*
    *  Now copy the memory.
    */
   **memcpy(dst, src, length)**;

  return 0;
 }

--
Ticket URL: <http://devel.rtems.org/ticket/4556>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list