[Replicant] [libsamsung-ipc] [PATCH 05/26] partitions: android: silence compiler warning
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Mon Mar 28 20:20:19 UTC 2022
Without that fix, when building the 'libsamsung-ipc' package through
scripts/guix.scm, we have the following warning:
CC partitions/android/android.lo
partitions/android/android.c:
In function ‘open_android_modem_partition_by_name’:
partitions/android/android.c:87:3: warning:
‘strncpy’ specified bound depends on the length of
the source argument [-Wstringop-overflow=]
87 | strncpy(path, partitions_dirnames[i],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88 | strlen(partitions_dirnames[i]));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC partitions/toc/toc.lo
CCLD libsamsung-ipc.la
The warning is hamless because:
- The source (partitions_dirnames[i]) is hardcoded.
- The desitination buffer size was allocated more space than
the length of partitions_dirnames[i].
However it's good to silence non problematic warnings in order to
better detect really serious issues.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
samsung-ipc/partitions/android/android.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/samsung-ipc/partitions/android/android.c b/samsung-ipc/partitions/android/android.c
index 9ec6ed4..9d2322f 100644
--- a/samsung-ipc/partitions/android/android.c
+++ b/samsung-ipc/partitions/android/android.c
@@ -84,8 +84,7 @@ int open_android_modem_partition_by_name(struct ipc_client *client,
return -errno;
}
- strncpy(path, partitions_dirnames[i],
- strlen(partitions_dirnames[i]));
+ strcpy(path, partitions_dirnames[i]);
strcat(path, name);
ipc_client_log(client, "%s: Trying to open %s",
--
2.35.1
More information about the Replicant
mailing list