apps/: Make more globals static to avoid name clashes

This commit is contained in:
Juha Niskanen 2017-05-19 07:13:12 -06:00 committed by Gregory Nutt
parent 22f48cfb5e
commit 0bcd50d7a1
14 changed files with 79 additions and 92 deletions

View File

@ -95,18 +95,17 @@ static struct mallinfo g_mmprevious;
static struct mallinfo g_mmafter;
#ifndef CONFIG_DISABLE_ENVIRON
const char g_var1_name[] = "Variable1";
const char g_var1_value[] = "GoodValue1";
const char g_var2_name[] = "Variable2";
const char g_var2_value[] = "GoodValue2";
const char g_var3_name[] = "Variable3";
const char g_var3_value[] = "GoodValue3";
static const char g_var1_name[] = "Variable1";
static const char g_var1_value[] = "GoodValue1";
static const char g_var2_name[] = "Variable2";
static const char g_var2_value[] = "GoodValue2";
static const char g_var3_name[] = "Variable3";
static const char g_var3_value[] = "GoodValue3";
const char g_bad_value1[] = "BadValue1";
const char g_bad_value2[] = "BadValue2";
const char g_putenv_value[] = "Variable1=BadValue3";
static const char g_bad_value1[] = "BadValue1";
static const char g_bad_value2[] = "BadValue2";
static const char g_putenv_value[] = "Variable1=BadValue3";
#endif
/****************************************************************************

View File

@ -63,10 +63,6 @@
#define sched_lock()
#define sched_unlock()
#ifndef NULL
# define NULL (void*)0
#endif
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
@ -82,7 +78,7 @@ static time_t g_start_time;
* Private Functions
****************************************************************************/
void my_mdelay(unsigned int milliseconds)
static void my_mdelay(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
@ -94,6 +90,7 @@ void my_mdelay(unsigned int milliseconds)
}
}
}
static void *nuisance_func(void *parameter)
{
/* Synchronized start */
@ -368,4 +365,4 @@ void sporadic_test(void)
}
}
#endif /* CONFIG_SCHED_SPORADIC */
#endif /* CONFIG_SCHED_SPORADIC */

View File

@ -49,7 +49,7 @@
* Private Data
****************************************************************************/
const char g_http[] = "http://";
static const char g_http[] = "http://";
#define HTTPLEN 7
/****************************************************************************

View File

@ -132,12 +132,6 @@ struct cdcacm_state_s
* Public Data
****************************************************************************/
/* All global variables used by this add-on are packed into a structure in
* order to avoid name collisions.
*/
extern struct cdcacm_state_s g_cdcacm;
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -58,7 +58,7 @@
* order to avoid name collisions.
*/
struct cdcacm_state_s g_cdcacm;
static struct cdcacm_state_s g_cdcacm;
/****************************************************************************
* Public Functions

View File

@ -78,10 +78,6 @@ struct cu_globals_s
* Public Data
****************************************************************************/
/* terminal state data */
extern struct cu_globals_s g_cu;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View File

@ -76,14 +76,12 @@ enum parity_mode
* Private Data
****************************************************************************/
static struct cu_globals_s g_cu;
/****************************************************************************
* Public Data
****************************************************************************/
/* terminal state data */
struct cu_globals_s g_cu;
/****************************************************************************
* Private Functions
****************************************************************************/

View File

@ -43,15 +43,67 @@
#include "i2ctool.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: arg_string
****************************************************************************/
static int arg_string(FAR char **arg, FAR char **value)
{
FAR char *ptr = *arg;
if (ptr[2] == '\0')
{
*value = arg[1];
return 2;
}
else
{
*value = &ptr[2];
return 1;
}
}
/****************************************************************************
* Name: arg_decimal
****************************************************************************/
static int arg_decimal(FAR char **arg, FAR long *value)
{
FAR char *string;
int ret;
ret = arg_string(arg, &string);
*value = strtol(string, NULL, 10);
return ret;
}
/****************************************************************************
* Name: arg_hex
****************************************************************************/
static int arg_hex(FAR char **arg, FAR long *value)
{
FAR char *string;
int ret;
ret = arg_string(arg, &string);
*value = strtol(string, NULL, 16);
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: common_args
* Name: i2ctool_common_args
****************************************************************************/
int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
int i2ctool_common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
{
FAR char *ptr = *arg;
long value;
@ -148,50 +200,3 @@ out_of_range:
return ERROR;
}
/****************************************************************************
* Name: arg_string
****************************************************************************/
int arg_string(FAR char **arg, FAR char **value)
{
FAR char *ptr = *arg;
if (ptr[2] == '\0')
{
*value = arg[1];
return 2;
}
else
{
*value = &ptr[2];
return 1;
}
}
/****************************************************************************
* Name: arg_decimal
****************************************************************************/
int arg_decimal(FAR char **arg, FAR long *value)
{
FAR char *string;
int ret;
ret = arg_string(arg, &string);
*value = strtol(string, NULL, 10);
return ret;
}
/****************************************************************************
* Name: arg_hex
****************************************************************************/
int arg_hex(FAR char **arg, FAR long *value)
{
FAR char *string;
int ret;
ret = arg_string(arg, &string);
*value = strtol(string, NULL, 16);
return ret;
}

View File

@ -88,7 +88,7 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
/* Otherwise, check for common options */
nargs = common_args(i2ctool, &argv[argndx]);
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
if (nargs < 0)
{
return ERROR;

View File

@ -79,7 +79,7 @@ int i2ccmd_get(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
/* Otherwise, check for common options */
nargs = common_args(i2ctool, &argv[argndx]);
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
if (nargs < 0)
{
return ERROR;

View File

@ -63,7 +63,7 @@ static int i2ccmd_unrecognized(FAR struct i2ctool_s *i2ctool, int argc, char **a
* Private Data
****************************************************************************/
struct i2ctool_s g_i2ctool;
static struct i2ctool_s g_i2ctool;
static const struct cmdmap_s g_i2ccmds[] =
{
@ -202,7 +202,8 @@ static int i2c_execute(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
* Name: i2c_argument
****************************************************************************/
FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool, int argc, char *argv[], int *pindex)
static FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool,
int argc, char *argv[], int *pindex)
{
FAR char *arg;
int index = *pindex;
@ -247,7 +248,7 @@ FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool, int argc, char *argv[], in
* Name: i2c_parse
****************************************************************************/
int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
static int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
{
FAR char *newargs[MAX_ARGUMENTS+2];
FAR char *cmd;

View File

@ -79,7 +79,7 @@ int i2ccmd_set(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
/* Otherwise, check for common options */
nargs = common_args(i2ctool, &argv[argndx]);
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
if (nargs < 0)
{
return ERROR;

View File

@ -81,7 +81,7 @@ int i2ccmd_verf(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
/* Otherwise, check for common options */
nargs = common_args(i2ctool, &argv[argndx]);
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
if (nargs < 0)
{
return ERROR;

View File

@ -199,10 +199,7 @@ int i2ctool_set(FAR struct i2ctool_s *i2ctool, int fd, uint8_t regaddr,
/* Common logic */
int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg);
int arg_string(FAR char **arg, FAR char **value);
int arg_decimal(FAR char **arg, FAR long *value);
int arg_hex(FAR char **arg, FAR long *value);
int i2ctool_common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg);
/* Driver access utilities */