Skip to content

Commit d66cf9b

Browse files
committed
[#341] initialize variables to 0, utilize defines
1 parent a0ac542 commit d66cf9b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

support/standalone/standalone.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int32_t crypto_standalone_get_command(const char *str)
113113

114114
int32_t crypto_standalone_process_command(int32_t cc, int32_t num_tokens, char *tokens)
115115
{
116-
int32_t status = CRYPTO_LIB_SUCCESS;
116+
int32_t status = 0;
117117

118118
/* Process command */
119119
switch (cc)
@@ -222,8 +222,8 @@ int32_t crypto_standalone_process_command(int32_t cc, int32_t num_tokens, char *
222222

223223
int32_t crypto_host_to_ip(const char *hostname, char *ip)
224224
{
225-
struct hostent *he;
226-
struct in_addr **addr_list;
225+
struct hostent *he = NULL;
226+
struct in_addr **addr_list = NULL;
227227

228228
if ((he = gethostbyname(hostname)) == NULL)
229229
{
@@ -578,7 +578,7 @@ void crypto_standalone_spp_telem_or_idle(int32_t *status_p, uint8_t *tm_ptr, uin
578578

579579
void *crypto_standalone_tm_process(void *socks)
580580
{
581-
int32_t status = CRYPTO_LIB_SUCCESS;
581+
int32_t status = 0;
582582
udp_interface_t *tm_socks = (udp_interface_t *)socks;
583583
udp_info_t *tm_read_sock = &tm_socks->read;
584584
udp_info_t *tm_write_sock = &tm_socks->write;
@@ -705,24 +705,23 @@ void crypto_standalone_cleanup(const int signal)
705705
/* Signal threads to stop */
706706
keepRunning = CRYPTO_LIB_ERROR;
707707
exit(signal);
708-
return;
709708
}
710709

711710
int main(int argc, char *argv[])
712711
{
713-
int32_t status = CRYPTO_LIB_SUCCESS;
712+
int32_t status = 0;
714713

715714
char input_buf[CRYPTO_MAX_INPUT_BUF];
716715
char input_tokens[CRYPTO_MAX_INPUT_TOKENS][CRYPTO_MAX_INPUT_TOKEN_SIZE];
717-
int num_input_tokens;
718-
int cmd;
719-
char *token_ptr;
716+
int num_input_tokens = 0;
717+
int cmd = 0;
718+
char *token_ptr = NULL;
720719

721720
udp_interface_t tc_apply;
722721
udp_interface_t tm_process;
723722

724-
pthread_t tc_apply_thread;
725-
pthread_t tm_process_thread;
723+
pthread_t tc_apply_thread = 0;
724+
pthread_t tm_process_thread = 0;
726725

727726
tc_apply.read.ip_address = CRYPTOLIB_HOSTNAME;
728727
tc_apply.read.port = TC_APPLY_PORT;
@@ -744,7 +743,7 @@ int main(int argc, char *argv[])
744743
signal(SIGINT, crypto_standalone_cleanup);
745744

746745
/* Startup delay */
747-
sleep(10);
746+
sleep(CRYPTO_STANDALONE_STARTUP_DELAY);
748747
// printf("Press enter once ground software has finished initializing...\n");
749748
// fgets(input_buf, CRYPTO_MAX_INPUT_BUF, stdin);
750749

support/standalone/standalone.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ extern "C"
5656
//#define CRYPTO_STANDALONE_TC_APPLY_DEBUG
5757
//#define CRYPTO_STANDALONE_TM_PROCESS_DEBUG
5858

59-
#define CRYPTO_STANDALONE_VCID_MAX 64
60-
#define CRYPTO_STANDALONE_IP_LEN 16
59+
#define CRYPTO_STANDALONE_VCID_MAX 64
60+
#define CRYPTO_STANDALONE_IP_LEN 16
61+
#define CRYPTO_STANDALONE_STARTUP_DELAY 10
6162
#define CRYPTO_STANDALONE_HANDLE_FRAMING
6263
#define CRYPTO_STANDALONE_FRAMING_BYPASS 0x20
6364
#define CRYPTO_STANDALONE_FRAMING_SCID 0x03 // 10 bits

0 commit comments

Comments
 (0)