WID:
12134324 Result of sizeof should not be assigned to 4 byte data type
socklen_t is typically a type that represents the length of socket-related
structures. It is defined as an integer type, and its size may vary between
platforms (e.g., 4 bytes on some systems, 8 bytes on others).
The sizeof(sockaddr) expression returns a size of type size_t, which is
often 8 bytes on 64-bit platforms. Assigning a size_t value (potentially
8 bytes) to a socklen_t (potentially 4 bytes) might cause truncation,
leading to this static analyzer warning.
While this is unlikely to cause actual issues in practice (since the size of
struct sockaddr_un is typically within the range of socklen_t), the static
analyzer points out the theoretical possibility of a mismatch.
Change-Id: I1c51d47b742e7cfeaa508a4e1f1906d8b123d3f0
sockaddr.sun_family = AF_UNIX;
strncpy(sockaddr.sun_path, SOCK_PATH, strlen(SOCK_PATH) + 1);
- len = sizeof(sockaddr);
+ len = (socklen_t)sizeof(sockaddr);
if (connect(sock, (struct sockaddr *)&sockaddr, len) < 0) {
_E("[CPU-BOOSTING-PLUGIN] Failed to connect to the resourced module");