summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-23 14:32:34 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-23 14:32:34 +0000
commit48751ab095bbbb23489c2e3243f57571cbfa9153 (patch)
tree7a15647c01c3acdb2d1c61142bb13616ad03a2aa /cpukit/libmisc/shell
parent2009-07-23 Santosh G Vattam <vattam.santosh@gmail.com> (diff)
downloadrtems-48751ab095bbbb23489c2e3243f57571cbfa9153.tar.bz2
2009-07-23 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_chmod.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c, libmisc/shell/shell_script.c, libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h: Convert return type from bool to rtems_status_code and add rtems_string_to_pointer. Perform associated clean up and changes for return type change. * libmisc/stringto/stringtopointer.c: New file.
Diffstat (limited to 'cpukit/libmisc/shell')
-rw-r--r--cpukit/libmisc/shell/main_chmod.c2
-rw-r--r--cpukit/libmisc/shell/main_mdump.c21
-rw-r--r--cpukit/libmisc/shell/main_medit.c8
-rw-r--r--cpukit/libmisc/shell/main_mfill.c17
-rw-r--r--cpukit/libmisc/shell/main_mmove.c18
-rw-r--r--cpukit/libmisc/shell/main_msdosfmt.c4
-rw-r--r--cpukit/libmisc/shell/main_mwdump.c12
-rw-r--r--cpukit/libmisc/shell/main_sleep.c4
-rw-r--r--cpukit/libmisc/shell/main_umask.c2
-rw-r--r--cpukit/libmisc/shell/shell_script.c4
10 files changed, 41 insertions, 51 deletions
diff --git a/cpukit/libmisc/shell/main_chmod.c b/cpukit/libmisc/shell/main_chmod.c
index 14e744255c..3c6ae68310 100644
--- a/cpukit/libmisc/shell/main_chmod.c
+++ b/cpukit/libmisc/shell/main_chmod.c
@@ -45,7 +45,7 @@ int rtems_shell_main_chmod(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Mode argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
index 9d597a9436..297ab6db0e 100644
--- a/cpukit/libmisc/shell/main_mdump.c
+++ b/cpukit/libmisc/shell/main_mdump.c
@@ -31,34 +31,30 @@ int rtems_shell_main_mdump(
char *argv[]
)
{
- unsigned long tmp;
unsigned char n;
unsigned char m;
int max;
int res;
- uintptr_t addr = 0;
+ void *addr = NULL;
unsigned char *pb;
if (argc > 1) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
}
- if (argc>2) {
- if ( !rtems_string_to_int(argv[1], &max, NULL, 0) ) {
+ if (argc > 2) {
+ if ( rtems_string_to_int(argv[1], &max, NULL, 0) ) {
printf( "Length argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
if (max <= 0) {
max = 1; /* print 1 item if 0 or neg. */
res = 0;
- }
- else {
+ } else {
max--;
res = max & 0xf;/* num bytes in last row */
max >>= 4; /* div by 16 */
@@ -68,14 +64,13 @@ int rtems_shell_main_mdump(
res = 0xf; /* 16 bytes print in last row */
}
}
- }
- else {
+ } else {
max = 20;
res = 0xf;
}
+ pb = addr;
for (m=0; m<max; m++) {
- pb = (unsigned char*) addr;
printf("%10p ", pb);
for (n=0;n<=(m==(max-1)?res:0xf);n++)
printf("%02X%c",pb[n],n==7?'-':' ');
@@ -85,7 +80,7 @@ int rtems_shell_main_mdump(
printf("%c", isprint(pb[n]) ? pb[n] : '.');
}
printf("\n");
- addr += 16;
+ pb += 16;
}
return 0;
}
diff --git a/cpukit/libmisc/shell/main_medit.c b/cpukit/libmisc/shell/main_medit.c
index c3f750f234..7905fbe689 100644
--- a/cpukit/libmisc/shell/main_medit.c
+++ b/cpukit/libmisc/shell/main_medit.c
@@ -32,8 +32,8 @@ int rtems_shell_main_medit(
char *argv[]
)
{
- unsigned long tmp;
unsigned char *pb;
+ void *tmpp;
int n;
int i;
@@ -45,11 +45,11 @@ int rtems_shell_main_medit(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &tmpp, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- pb = (unsigned char *) tmp;
+ pb = tmpp;
/*
* Now edit the memory
@@ -58,7 +58,7 @@ int rtems_shell_main_medit(
for (i=2 ; i<=argc ; i++) {
unsigned char tmpc;
- if ( !rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
printf( "Value (%s) is not a number\n", argv[i] );
continue;
}
diff --git a/cpukit/libmisc/shell/main_mfill.c b/cpukit/libmisc/shell/main_mfill.c
index 1fb027ae4f..ecbaec4878 100644
--- a/cpukit/libmisc/shell/main_mfill.c
+++ b/cpukit/libmisc/shell/main_mfill.c
@@ -30,10 +30,10 @@ int rtems_shell_main_mfill(
char *argv[]
)
{
- unsigned long tmp;
- uintptr_t addr;
- size_t size;
- unsigned char value;
+ unsigned long tmp;
+ void *addr;
+ size_t size;
+ unsigned char value;
if ( argc != 4 ) {
fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -43,19 +43,18 @@ int rtems_shell_main_mfill(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
printf( "Size argument (%s) is not a number\n", argv[2] );
return -1;
}
size = (size_t) tmp;
- if ( !rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
printf( "Value argument (%s) is not a number\n", argv[3] );
return -1;
}
@@ -63,7 +62,7 @@ int rtems_shell_main_mfill(
/*
* Now fill the memory.
*/
- memset((unsigned char*)addr, size, value);
+ memset(addr, size, value);
return 0;
}
diff --git a/cpukit/libmisc/shell/main_mmove.c b/cpukit/libmisc/shell/main_mmove.c
index f68f4a2ab6..30c6629547 100644
--- a/cpukit/libmisc/shell/main_mmove.c
+++ b/cpukit/libmisc/shell/main_mmove.c
@@ -32,10 +32,10 @@ int rtems_shell_main_mmove(
char *argv[]
)
{
- unsigned long tmp;
- uintptr_t src;
- uintptr_t dst;
- size_t length;
+ unsigned long tmp;
+ void *src;
+ void *dst;
+ size_t length;
if ( argc < 4 ) {
fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -45,19 +45,17 @@ int rtems_shell_main_mmove(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) {
printf( "Destination argument (%s) is not a number\n", argv[1] );
return -1;
}
- dst = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[2], &src, NULL) ) {
printf( "Source argument (%s) is not a number\n", argv[2] );
return -1;
}
- src = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
printf( "Length argument (%s) is not a number\n", argv[3] );
return -1;
}
@@ -66,7 +64,7 @@ int rtems_shell_main_mmove(
/*
* Now copy the memory.
*/
- memcpy((unsigned char*)dst, (unsigned char*)src, length);
+ memcpy(dst, src, length);
return 0;
}
diff --git a/cpukit/libmisc/shell/main_msdosfmt.c b/cpukit/libmisc/shell/main_msdosfmt.c
index d682728b9d..493ae25799 100644
--- a/cpukit/libmisc/shell/main_msdosfmt.c
+++ b/cpukit/libmisc/shell/main_msdosfmt.c
@@ -64,7 +64,7 @@ int rtems_shell_main_msdos_format(
return 1;
}
- if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
printf(
"sector per cluster argument (%s) is not a number\n",
argv[arg]
@@ -82,7 +82,7 @@ int rtems_shell_main_msdos_format(
return 1;
}
- if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
printf(
"root directory size argument (%s) is not a number\n",
argv[arg]
diff --git a/cpukit/libmisc/shell/main_mwdump.c b/cpukit/libmisc/shell/main_mwdump.c
index 6c6c77dcc0..9520f1e773 100644
--- a/cpukit/libmisc/shell/main_mwdump.c
+++ b/cpukit/libmisc/shell/main_mwdump.c
@@ -31,24 +31,22 @@ int rtems_shell_main_mwdump(
char *argv[]
)
{
- unsigned long tmp;
unsigned char n;
unsigned char m;
int max;
int res;
- uintptr_t addr = 0;
+ void *addr = 0;
unsigned char *pb;
if ( argc > 1 ) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
}
if ( argc > 2 ) {
- if ( !rtems_string_to_int(argv[2], &max, NULL, 0) ) {
+ if ( rtems_string_to_int(argv[2], &max, NULL, 0) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
@@ -71,8 +69,8 @@ int rtems_shell_main_mwdump(
res = 0xf;
}
+ pb = addr;
for (m=0;m<max;m++) {
- pb = (unsigned char *) addr;
printf("%10p ", pb);
for (n=0;n<=(m==(max-1)?res:0xf);n+=2)
printf("%04X%c",*((unsigned short*)(pb+n)),n==6?'-':' ');
@@ -82,7 +80,7 @@ int rtems_shell_main_mwdump(
printf("%c", isprint(pb[n]) ? pb[n] : '.');
}
printf("\n");
- addr += 16;
+ pb += 16;
}
return 0;
}
diff --git a/cpukit/libmisc/shell/main_sleep.c b/cpukit/libmisc/shell/main_sleep.c
index b153f62d37..2dbb66a996 100644
--- a/cpukit/libmisc/shell/main_sleep.c
+++ b/cpukit/libmisc/shell/main_sleep.c
@@ -39,7 +39,7 @@ int rtems_shell_main_sleep(
/*
* Convert the seconds argument to a number
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Seconds argument (%s) is not a number\n", argv[1] );
return -1;
}
@@ -50,7 +50,7 @@ int rtems_shell_main_sleep(
*/
delay.tv_nsec = 0;
if (argc == 3) {
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
printf( "Seconds argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/main_umask.c b/cpukit/libmisc/shell/main_umask.c
index 30996f187f..8bfbe7e443 100644
--- a/cpukit/libmisc/shell/main_umask.c
+++ b/cpukit/libmisc/shell/main_umask.c
@@ -37,7 +37,7 @@ int rtems_shell_main_umask(
mode_t msk = umask(0);
if (argc == 2) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Mask argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/shell_script.c b/cpukit/libmisc/shell/shell_script.c
index c31ed051d3..95b5abb934 100644
--- a/cpukit/libmisc/shell/shell_script.c
+++ b/cpukit/libmisc/shell/shell_script.c
@@ -129,7 +129,7 @@ int rtems_shell_main_joel(
case 'p': {
const char *s = getopt_reent.optarg;
- if ( !rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
printf( "Task Priority argument (%s) is not a number\n", s );
return -1;
}
@@ -139,7 +139,7 @@ int rtems_shell_main_joel(
case 's': {
const char *s = getopt_reent.optarg;
- if ( !rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
printf( "Stack size argument (%s) is not a number\n", s );
return -1;
}