Author: biurrun Date: Thu Nov 26 17:15:37 2009 New Revision: 1827 Log: Move create_error_struct() to the only place it is used and mark it static. Modified: trunk/pairing/common_headers.c trunk/pairing/common_headers.h trunk/pairing/packet_handler_accept.c Modified: trunk/pairing/common_headers.c ============================================================================== --- trunk/pairing/common_headers.c Thu Nov 26 17:11:06 2009 (r1826) +++ trunk/pairing/common_headers.c Thu Nov 26 17:15:37 2009 (r1827) @@ -14,39 +14,6 @@ #include "common_headers.h" -/** Creates an error structure and fills it with the information given. - * - * @param error_type Error type (use macros ERROR_*) - * @param error_string Pointer to string containing an error message. - * - * @return A pointer to the header_general structure. Returns NULL on error. - */ -header_general* create_error_struct(int error_type, const char *error_string) -{ - if (error_string == NULL) - { - DEBUG("No error string given. Error structure was not created."); - return NULL; - } - - header_general *gen_hdr = malloc(sizeof(header_general)); - gen_hdr->msg_type = MSG_ERROR; - gen_hdr->msg.header_error.error_type = error_type; - strncpy((char*)&((gen_hdr->msg.header_error).error_string), error_string, LENGTH_ERROR_STRING); - - DEBUG_HIGH(LINE_BREAK); - DEBUG_HIGH("General header created."); - DEBUG_HIGH("\tMessage type: %d", gen_hdr->msg_type); - DEBUG_HIGH("Error structure created:"); - DEBUG_HIGH("\tError type: %d", gen_hdr->msg.header_error.error_type); - DEBUG_HIGH("\tError string: %s", (gen_hdr->msg.header_error).error_string); - DEBUG_HIGH(LINE_BREAK); - - return gen_hdr; -} - - - /** This message formats and prints out relevant message info (type, return value). * * @param msg_type An integer describing the message type Modified: trunk/pairing/common_headers.h ============================================================================== --- trunk/pairing/common_headers.h Thu Nov 26 17:11:06 2009 (r1826) +++ trunk/pairing/common_headers.h Thu Nov 26 17:15:37 2009 (r1827) @@ -82,7 +82,6 @@ // Function prototypes -header_general* create_error_struct(int error_type, const char *error_string); void print_msg_info(int msg_type, int return_value); #endif /* PISA_COMMON_HEADERS_H */ Modified: trunk/pairing/packet_handler_accept.c ============================================================================== --- trunk/pairing/packet_handler_accept.c Thu Nov 26 17:11:06 2009 (r1826) +++ trunk/pairing/packet_handler_accept.c Thu Nov 26 17:15:37 2009 (r1827) @@ -23,6 +23,39 @@ #define ERROR_NOT_CONNECTED 1 +/** Creates an error structure and fills it with the information given. + * + * @param error_type Error type (use macros ERROR_*) + * @param error_string Pointer to string containing an error message. + * + * @return A pointer to the header_general structure. Returns NULL on error. + */ +static header_general* create_error_struct(int error_type, + const char *error_string) +{ + if (error_string == NULL) + { + DEBUG("No error string given. Error structure was not created."); + return NULL; + } + + header_general *gen_hdr = malloc(sizeof(header_general)); + gen_hdr->msg_type = MSG_ERROR; + gen_hdr->msg.header_error.error_type = error_type; + strncpy((char*)&((gen_hdr->msg.header_error).error_string), error_string, LENGTH_ERROR_STRING); + + DEBUG_HIGH(LINE_BREAK); + DEBUG_HIGH("General header created."); + DEBUG_HIGH("\tMessage type: %d", gen_hdr->msg_type); + DEBUG_HIGH("Error structure created:"); + DEBUG_HIGH("\tError type: %d", gen_hdr->msg.header_error.error_type); + DEBUG_HIGH("\tError string: %s", (gen_hdr->msg.header_error).error_string); + DEBUG_HIGH(LINE_BREAK); + + return gen_hdr; +} + + /** Creates a header_general structure which holds a header_ack_1 structure and fills both. * * @return A pointer to the header_general structure. Returns NULL on error.