[mavlink] simplify null termination of string

strncpy already copies the terminating null byte, except if the string is longer than 49 chars
This commit is contained in:
Felix Ruess
2015-11-22 13:22:16 +01:00
parent c697021117
commit 84f559a725
@@ -50,10 +50,8 @@ void mavlink_send_block(uint16_t seq)
static const char *blocks[] = FP_BLOCKS;
char block_name[50];
strncpy(block_name, blocks[seq], 49); // String containing the name of the block
uint8_t _terminate = strlen(blocks[seq]); // Length of the block name
if (_terminate > 49)
_terminate = 49;
block_name[_terminate] = 0;
// make sure the string is null terminated if longer than 49chars
block_name[49] = 0;
mavlink_msg_script_item_send(MAVLINK_COMM_0, mission_mgr.rem_sysid, mission_mgr.rem_compid,
seq, block_name);
MAVLinkSendMessage();