[tuxdroid-svn] r1070 - software_suite_v2/middleware/tuxdriver/trunk/src
Status: Beta
Brought to you by:
ks156
From: eFfeM <c2m...@c2...> - 2008-05-02 10:29:02
|
Author: eFfeM Date: 2008-05-02 12:29:05 +0200 (Fri, 02 May 2008) New Revision: 1070 Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.c Log: added const to a lot of function arguments, on the fly did one or two cleanups Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c 2008-05-02 10:13:15 UTC (rev 1069) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c 2008-05-02 10:29:05 UTC (rev 1070) @@ -72,7 +72,7 @@ * */ static inline bool match_token(tokens_t tokens, int i, int t_num, - char *str, int t_count) + const char *str, int t_count) { return (i >= t_count) && (!strcmp(tokens[t_num], str)); } @@ -106,13 +106,13 @@ * */ LIBLOCAL int -tux_cmd_parser_get_tokens(char *src_str, tokens_t *toks, - int max_tokens, char *delimiters) +tux_cmd_parser_get_tokens(const char *src_str, tokens_t *toks, + int max_tokens, const char *delimiters) { - char *p; /* pointer to the next token */ - char *pnext; /* pointer to the next delimiter */ - int len; /* length of the next token */ - int cnt = 0; /* nr of tokens processed */ + const char *p; /* pointer to the next token */ + const char *pnext; /* pointer to the next delimiter */ + int len; /* length of the next token */ + int cnt = 0; /* nr of tokens processed */ p = src_str; @@ -129,7 +129,7 @@ if (pnext) { len = pnext - p; - strncpy((*toks)[cnt], p,len); + strncpy((*toks)[cnt], p, len); ((*toks)[cnt])[len] = 0; cnt++; if (cnt >= max_tokens) @@ -154,7 +154,7 @@ * */ static unsigned char -tux_movement_conststr_to_val(char *conststr) +tux_movement_conststr_to_val(const char *conststr) { if (!strcmp(conststr, "VERYLOW")) { @@ -207,7 +207,7 @@ * */ static unsigned char -conststr_to_ledval(char *conststr) +conststr_to_ledval(const char *conststr) { if (!strcmp(conststr, "LED_NONE")) { @@ -232,7 +232,7 @@ * */ static unsigned char -conststr_to_effectval(char *conststr) +conststr_to_effectval(const char *conststr) { if (!strcmp(conststr, "UNAFFECTED")) { @@ -712,7 +712,7 @@ * Parse a command. */ LIBLOCAL TuxDrvError -tux_cmd_parser_parse_command(char *cmd_str) +tux_cmd_parser_parse_command(const char *cmd_str) { tokens_t tokens; int nr_tokens; @@ -780,7 +780,7 @@ * */ static TuxDrvError -insert_cmd(float delay, char *cmd_str, cmd_stack_t *stack) +insert_cmd(float delay, const char *cmd_str, cmd_stack_t *stack) { TuxDrvError ret = E_TUXDRV_STACKOVERFLOW; int i; @@ -803,7 +803,8 @@ * */ LIBLOCAL TuxDrvError -tux_cmd_parser_insert_delay_command(float delay, char *cmd_str, bool sys_cmd) +tux_cmd_parser_insert_delay_command(float delay, const char *cmd_str, + bool sys_cmd) { TuxDrvError ret = E_TUXDRV_STACKOVERFLOW; @@ -912,7 +913,7 @@ * */ static TuxDrvError -parse_line(char *line_str) +parse_line(const char *line_str) { float delay= 0.0; char cmd_str[CMDSIZE] = ""; @@ -933,7 +934,7 @@ * */ LIBLOCAL TuxDrvError -tux_cmd_parser_parse_macro(char *macro_str) +tux_cmd_parser_parse_macro(const char *macro_str) { const char lex_ret[] = "\n"; char *line_tmp; @@ -978,7 +979,7 @@ * */ LIBLOCAL TuxDrvError -tux_cmd_parser_parse_file(char *file_path) +tux_cmd_parser_parse_file(const char *file_path) { char line[CMDSIZE] = ""; FILE *macro_file; Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.h 2008-05-02 10:13:15 UTC (rev 1069) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.h 2008-05-02 10:29:05 UTC (rev 1070) @@ -33,14 +33,14 @@ extern void tux_cmd_parser_init(void); extern void tux_cmd_parser_set_enable(bool value); -extern int tux_cmd_parser_get_tokens(char *src_str, tokens_t *toks, - int max_tokens, char *delimiters); -extern TuxDrvError tux_cmd_parser_parse_command(char *cmd_str); +extern int tux_cmd_parser_get_tokens(const char *src_str, tokens_t *toks, + int max_tokens, const char *delimiters); +extern TuxDrvError tux_cmd_parser_parse_command(const char *cmd_str); extern bool tux_cmd_parser_clear_delay_commands(void); extern TuxDrvError tux_cmd_parser_insert_delay_command(float delay, - char *cmd_str, bool sys_cmd); + const char *cmd_str, bool sys_cmd); extern void tux_cmd_parser_delay_stack_perform(void); -extern TuxDrvError tux_cmd_parser_parse_macro(char *macro_str); -extern TuxDrvError tux_cmd_parser_parse_file(char *file_path); +extern TuxDrvError tux_cmd_parser_parse_macro(const char *macro_str); +extern TuxDrvError tux_cmd_parser_parse_file(const char *file_path); #endif /* _TUX_CMD_PARSER_H_ */ Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.c 2008-05-02 10:13:15 UTC (rev 1069) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.c 2008-05-02 10:29:05 UTC (rev 1070) @@ -53,7 +53,7 @@ * @param id cpu identifier. * @return a string. */ -static char * +static const char * cpu_id_to_name(int id) { switch (id) @@ -81,7 +81,7 @@ { #ifdef LOCK_TUX FILE *f; - char ret_str[3] = "\n"; + char ret_str[] = "\n"; char *ret_c; f = fopen("./symbolic_versions", "r"); @@ -90,23 +90,23 @@ fgets(knowed_tuxcore_symbolic_version, sizeof(knowed_tuxcore_symbolic_version)-2, f); ret_c = strstr(knowed_tuxcore_symbolic_version, ret_str); - *(char *)ret_c = '\0'; + *ret_c = '\0'; fgets(knowed_tuxaudio_symbolic_version, sizeof(knowed_tuxaudio_symbolic_version)-2, f); ret_c = strstr(knowed_tuxaudio_symbolic_version, ret_str); - *(char *)ret_c = '\0'; + *ret_c = '\0'; fgets(knowed_fuxusb_symbolic_version, sizeof(knowed_fuxusb_symbolic_version)-2, f); ret_c = strstr(knowed_fuxusb_symbolic_version, ret_str); - *(char *)ret_c = '\0'; + *ret_c = '\0'; fgets(knowed_fuxrf_symbolic_version, sizeof(knowed_fuxrf_symbolic_version)-2, f); ret_c = strstr(knowed_fuxrf_symbolic_version, ret_str); - *(char *)ret_c = '\0'; + *ret_c = '\0'; fgets(knowed_tuxrf_symbolic_version, sizeof(knowed_tuxrf_symbolic_version)-2, f); ret_c = strstr(knowed_tuxrf_symbolic_version, ret_str); - *(char *)ret_c = '\0'; + *ret_c = '\0'; fclose(f); } #endif @@ -187,7 +187,7 @@ * */ static void -dump_descriptor_of_cpu(char *descriptor, firmware_descriptor_t *desc) +dump_descriptor_of_cpu(char *descriptor, const firmware_descriptor_t *desc) { char tmp_str[80] = ""; @@ -403,7 +403,8 @@ * */ static bool -test_fw_ver(firmware_descriptor_t *firmware, int major, int minor, int update) +test_fw_ver(const firmware_descriptor_t *firmware, int major, int minor, + int update) { if ((firmware->version_major != major) || (firmware->version_minor != minor) || |