summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Brand <tom@trellis.ch>2019-01-26 04:26:10 +0100
committerThomas Brand <tom@trellis.ch>2019-01-26 04:26:10 +0100
commit1050436b33a3a5d27fa752228fe302028d67fc03 (patch)
tree8e5aad4eecb3e7bc57b89b2007c136e97fff1453
parent667e06890ef47a533a616a5f5661a1d2cae5ffdb (diff)
downloadjack2-1050436b33a3a5d27fa752228fe302028d67fc03.tar.gz
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. !!
-rw-r--r--tests/test.cpp6
1 files 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);