forked from Imagelibrary/rtems
libtests/stringto01: Fix for GCC 5.0
This commit is contained in:
@@ -26,6 +26,11 @@ rtems_task Init(rtems_task_argument argument);
|
|||||||
#define __STRING(x) #x /* stringify without expanding x */
|
#define __STRING(x) #x /* stringify without expanding x */
|
||||||
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
|
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
|
||||||
|
|
||||||
|
static int get_base_10_or_16(const char *s)
|
||||||
|
{
|
||||||
|
return (s[0] == '0' && s[1] == 'x') ? 16 : 10;
|
||||||
|
}
|
||||||
|
|
||||||
/* c99 has LLONG_MAX instead of LONG_LONG_MAX */
|
/* c99 has LLONG_MAX instead of LONG_LONG_MAX */
|
||||||
#ifndef LONG_LONG_MAX
|
#ifndef LONG_LONG_MAX
|
||||||
#define LONG_LONG_MAX LLONG_MAX
|
#define LONG_LONG_MAX LLONG_MAX
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" - NULL return value - RTEMS_INVALID_ADDRESS"
|
" - NULL return value - RTEMS_INVALID_ADDRESS"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, NULL, &endptr, 10 );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, NULL, &endptr,
|
||||||
|
get_base_10_or_16( GOOD_VALUE_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, NULL, &endptr );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, NULL, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -52,7 +53,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" NULL endptr return value - RTEMS_SUCCESSFUL"
|
" NULL endptr return value - RTEMS_SUCCESSFUL"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, NULL, 10 );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, NULL,
|
||||||
|
get_base_10_or_16( GOOD_VALUE_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, NULL );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, NULL );
|
||||||
#endif
|
#endif
|
||||||
@@ -67,8 +69,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" w/endptr return value - RTEMS_SUCCESSFUL"
|
" w/endptr return value - RTEMS_SUCCESSFUL"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD(
|
status = STRING_TO_NAME_METHOD( STRING_TO_MAX_STRING, &value, &endptr,
|
||||||
STRING_TO_MAX_STRING, &value, &endptr, 10 );
|
get_base_10_or_16( STRING_TO_MAX_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( STRING_TO_MAX_STRING, &value, &endptr );
|
status = STRING_TO_NAME_METHOD( STRING_TO_MAX_STRING, &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -84,7 +86,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" w/endptr return value - RTEMS_SUCCESSFUL"
|
" w/endptr return value - RTEMS_SUCCESSFUL"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, &endptr, 10 );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, &endptr,
|
||||||
|
get_base_10_or_16( GOOD_VALUE_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, &endptr );
|
status = STRING_TO_NAME_METHOD( GOOD_VALUE_STRING, &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -99,7 +102,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" w/endptr return value - RTEMS_NOT_DEFINED"
|
" w/endptr return value - RTEMS_NOT_DEFINED"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD( BAD_VALUE_STRING, &value, &endptr, 10 );
|
status = STRING_TO_NAME_METHOD( BAD_VALUE_STRING, &value, &endptr,
|
||||||
|
get_base_10_or_16( BAD_VALUE_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( BAD_VALUE_STRING, &value, &endptr );
|
status = STRING_TO_NAME_METHOD( BAD_VALUE_STRING, &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -114,7 +118,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
" - empty string - w/endptr return value - RTEMS_NOT_DEFINED"
|
" - empty string - w/endptr return value - RTEMS_NOT_DEFINED"
|
||||||
);
|
);
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD( "", &value, &endptr, 10 );
|
status = STRING_TO_NAME_METHOD( "", &value, &endptr,
|
||||||
|
get_base_10_or_16( "" ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( "", &value, &endptr );
|
status = STRING_TO_NAME_METHOD( "", &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -129,8 +134,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
puts(
|
puts(
|
||||||
STRING_TO_NAME_METHOD_STRING " - overflow - RTEMS_INVALID_NUMBER" );
|
STRING_TO_NAME_METHOD_STRING " - overflow - RTEMS_INVALID_NUMBER" );
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD(
|
status = STRING_TO_NAME_METHOD( TEST_TOO_LARGE_STRING, &value, &endptr,
|
||||||
TEST_TOO_LARGE_STRING, &value, &endptr, 10 );
|
get_base_10_or_16( TEST_TOO_LARGE_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( TEST_TOO_LARGE_STRING, &value, &endptr );
|
status = STRING_TO_NAME_METHOD( TEST_TOO_LARGE_STRING, &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
@@ -148,8 +153,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
puts(
|
puts(
|
||||||
STRING_TO_NAME_METHOD_STRING " - overflow - RTEMS_INVALID_NUMBER" );
|
STRING_TO_NAME_METHOD_STRING " - overflow - RTEMS_INVALID_NUMBER" );
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD(
|
status = STRING_TO_NAME_METHOD( TEST_TOO_LARGE_FOR_UCHAR, &value,
|
||||||
TEST_TOO_LARGE_FOR_UCHAR, &value, &endptr, 10 );
|
&endptr, get_base_10_or_16( TEST_TOO_LARGE_FOR_UCHAR ) );
|
||||||
#endif
|
#endif
|
||||||
if ( status != RTEMS_INVALID_NUMBER )
|
if ( status != RTEMS_INVALID_NUMBER )
|
||||||
printf( "ERROR = %s\n", rtems_status_text(status) );
|
printf( "ERROR = %s\n", rtems_status_text(status) );
|
||||||
@@ -163,8 +168,8 @@ void TEST_STRING_TO_NAME(void)
|
|||||||
value = 0;
|
value = 0;
|
||||||
puts( STRING_TO_NAME_METHOD_STRING "- RTEMS_INVALID_NUMBER" );
|
puts( STRING_TO_NAME_METHOD_STRING "- RTEMS_INVALID_NUMBER" );
|
||||||
#if defined(STRING_TO_INTEGER)
|
#if defined(STRING_TO_INTEGER)
|
||||||
status = STRING_TO_NAME_METHOD(
|
status = STRING_TO_NAME_METHOD( TEST_TOO_SMALL_STRING, &value, &endptr,
|
||||||
TEST_TOO_SMALL_STRING, &value, &endptr, 10 );
|
get_base_10_or_16( TEST_TOO_SMALL_STRING ) );
|
||||||
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
#elif defined(STRING_TO_POINTER) || defined(STRING_TO_FLOAT)
|
||||||
status = STRING_TO_NAME_METHOD( TEST_TOO_SMALL_STRING, &value, &endptr );
|
status = STRING_TO_NAME_METHOD( TEST_TOO_SMALL_STRING, &value, &endptr );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user