Browse Source

Use memset to fill buffer. Add test marker.

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. !!
Thomas Brand 4 years ago
1 changed files with 3 additions and 3 deletions
  1. +3

+ 3
- 3
tests/test.cpp View File

@@ -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);