[rtems commit] shell.c: Add cast to match printf() expectations for width specifier

Joel Sherrill joel at rtems.org
Thu Sep 4 13:59:25 UTC 2014


Module:    rtems
Branch:    master
Commit:    06ac8b7122cc2b7c660cb34beb82414630b8a306
Changeset: http://git.rtems.org/rtems/commit/?id=06ac8b7122cc2b7c660cb34beb82414630b8a306

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Wed Sep  3 09:59:37 2014 -0500

shell.c: Add cast to match printf() expectations for width specifier

---

 cpukit/libmisc/shell/shell.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index a94724f..eeb60dc 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -306,7 +306,12 @@ static int rtems_shell_line_editor(
 
         case 7:                         /* Control-G */
           if (output) {
-            fprintf(out,"\r%s%*c", prompt, strlen (line), ' ');
+            /*
+             * The (int) cast is needed because the width specifier (%*)
+             * must be an int, but strlen() returns a size_t. Without
+             * the case, the result is a printf() format warning.
+             */
+            fprintf(out,"\r%s%*c", prompt, (int) strlen (line), ' ');
             fprintf(out,"\r%s\x7", prompt);
           }
           memset (line, '\0', strlen(line));



More information about the vc mailing list