PengZheng commented on code in PR #734: URL: https://github.com/apache/celix/pull/734#discussion_r1510544621
########## libs/framework/src/bundle_context.c: ########## @@ -1058,11 +1082,10 @@ bool celix_bundleContext_useServiceWithId( const char *serviceName, void *callbackHandle, void (*use)(void *handle, void *svc)) { - celix_service_use_options_t opts = CELIX_EMPTY_SERVICE_USE_OPTIONS; - - char filter[64]; - snprintf(filter, 64, "(%s=%li)", CELIX_FRAMEWORK_SERVICE_ID, serviceId); + char filter[32]; //20 is max long length + (void)snprintf(filter, sizeof(filter), "(%s=%li)", CELIX_FRAMEWORK_SERVICE_ID, serviceId); Review Comment: A long can take value `INT64_MIN`, which need 20 bytes(including the leading `-`). The total length of the buffer needs to be 1 (`(`) + 10 (CELIX_FRAMEWORK_SERVICE_ID) + 1 (`=`) + 20 (`%li`) + 1 (`)`) + 1 ('\0') = 34 bytes. This modification (`-Wstringop-truncation`) will lead to gcc warning complaining string truncation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org