From 1050436b33a3a5d27fa752228fe302028d67fc03 Mon Sep 17 00:00:00 2001 From: Thomas Brand Date: Sat, 26 Jan 2019 04:26:10 +0100 Subject: [PATCH] Use memset to fill buffer. Add test marker. Notes: The name length test still fails. jack_client_open() will only allow 63 printable chars (unlike expected 64 == JACK_CLIENT_NAME_SIZE). This difference isn't explained by the terminating NULL character. jack_client_name_size() takes care of that (returns JACK_CLIENT_NAME_SIZE + 1). char arrays are initialized like arr[JACK_CLIENT_NAME_SIZE + 1] in many files und truncated like arr[JACK_CLIENT_NAME_SIZE]. Probable reason for 63: ':' is part of the client name and implicitely added later. Name used by caller does not include ':' thus jack_client_open() will allow only JACK_CLIENT_NAME_SIZE - 1 printable chars. This line in common/JackConstants.h gives a hint that ':' might be counted in for JACK_CLIENT_NAME_SIZE #define REAL_JACK_PORT_NAME_SIZE JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE // full name like "client_name:short_port_name" Currently many char arguments are described like @param client_name of at most jack_client_name_size() characters This can be confusing in two ways: -jack_client_name_size() does include the NULL so it's one less 'payload' character -if the returned size is used exactly as described for function jack_client_name_size() including NULL, it won't work with jack_client_open() or jack_port_register() etc. because of another reduction (eventually for the ":"). !! This needs to be verified and documentation needs to be reviewed. !! --- tests/test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.cpp b/tests/test.cpp index e7326e9c..87e8b1bc 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -749,9 +749,9 @@ int main (int argc, char *argv[]) */ char client_name3[jack_client_name_size()]; // "jack_client_name_size" - 1 effective characters - for (int i = 0; i < jack_client_name_size() - 1; i++) { - client_name3[i] = 'A'; - } + memset(client_name3, 'A', sizeof(client_name3)); + // set last expected printable to 'X' + client_name3[jack_client_name_size()-2] = 'X'; // And last one is the terminating '0' client_name3[jack_client_name_size()-1] = 0; Log("trying to register a new jackd client with maximum possible client name size...\n", client_name3);