0017-harness-Use-destination-strncpy-expression-for-sizeo.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From b9e17f6afdc4d0e81b1598aecea7b80d0c54b13a Mon Sep 17 00:00:00 2001
  2. From: Guillem Jover <guillem@hadrons.org>
  3. Date: Sat, 20 Jul 2019 21:20:58 +0200
  4. Subject: [PATCH libaio 17/28] harness: Use destination strncpy() expression
  5. for sizeof() argument
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Even though this is the same size, as the sizeof() is derived from the
  10. source expression, recent gcc versions will emit a warning, which is
  11. turned into an error by -Werror:
  12. error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression
  13. as the source; did you mean to use the size of the destination?
  14. [-Werror=sizeof-pointer-memaccess]
  15. Signed-off-by: Guillem Jover <guillem@hadrons.org>
  16. Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
  17. ---
  18. harness/cases/19.t | 2 +-
  19. harness/cases/21.t | 2 +-
  20. 2 files changed, 2 insertions(+), 2 deletions(-)
  21. diff --git a/harness/cases/19.t b/harness/cases/19.t
  22. index 4989510..5c3e0d6 100644
  23. --- a/harness/cases/19.t
  24. +++ b/harness/cases/19.t
  25. @@ -41,7 +41,7 @@ open_temp_file(void)
  26. int fd;
  27. char template[sizeof(TEMPLATE)];
  28. - strncpy(template, TEMPLATE, sizeof(TEMPLATE));
  29. + strncpy(template, TEMPLATE, sizeof(template));
  30. fd = mkostemp(template, O_DIRECT);
  31. if (fd < 0) {
  32. perror("mkstemp");
  33. diff --git a/harness/cases/21.t b/harness/cases/21.t
  34. index 441eaa8..fe33a9d 100644
  35. --- a/harness/cases/21.t
  36. +++ b/harness/cases/21.t
  37. @@ -43,7 +43,7 @@ open_temp_file()
  38. int fd;
  39. char temp_file[sizeof(TEMPLATE)];
  40. - strncpy(temp_file, TEMPLATE, sizeof(TEMPLATE));
  41. + strncpy(temp_file, TEMPLATE, sizeof(temp_file));
  42. fd = mkstemp(temp_file);
  43. if (fd < 0) {
  44. perror("mkstemp");
  45. --
  46. 2.26.0.292.g33ef6b2f38