logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0009-Avoid-unnecessary-VLA.patch (1524B)


  1. From fac76bb5a8d1b03db9aa68c3bd72999ce76b8ca5 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Sat, 21 Jan 2023 17:41:15 -0800
  4. Subject: [PATCH] Avoid unnecessary VLA
  5. ---
  6. cmd/zpool/zpool_vdev.c | 17 ++++++++---------
  7. 1 file changed, 8 insertions(+), 9 deletions(-)
  8. diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c
  9. index fbd4b81df..a45ab7af5 100644
  10. --- a/cmd/zpool/zpool_vdev.c
  11. +++ b/cmd/zpool/zpool_vdev.c
  12. @@ -910,8 +910,7 @@ check_replication(nvlist_t *config, nvlist_t *newroot)
  13. static int
  14. zero_label(const char *path)
  15. {
  16. - const int size = 4096;
  17. - char buf[size];
  18. + char buf[4096];
  19. int err, fd;
  20. if ((fd = open(path, O_WRONLY|O_EXCL)) < 0) {
  21. @@ -920,20 +919,20 @@ zero_label(const char *path)
  22. return (-1);
  23. }
  24. - memset(buf, 0, size);
  25. - err = write(fd, buf, size);
  26. + memset(buf, 0, sizeof (buf));
  27. + err = write(fd, buf, sizeof (buf));
  28. (void) fdatasync(fd);
  29. (void) close(fd);
  30. if (err == -1) {
  31. - (void) fprintf(stderr, gettext("cannot zero first %d bytes "
  32. - "of '%s': %s\n"), size, path, strerror(errno));
  33. + (void) fprintf(stderr, gettext("cannot zero first %zu bytes "
  34. + "of '%s': %s\n"), sizeof (buf), path, strerror(errno));
  35. return (-1);
  36. }
  37. - if (err != size) {
  38. - (void) fprintf(stderr, gettext("could only zero %d/%d bytes "
  39. - "of '%s'\n"), err, size, path);
  40. + if (err != sizeof (buf)) {
  41. + (void) fprintf(stderr, gettext("could only zero %d/%zu bytes "
  42. + "of '%s'\n"), err, sizeof (buf), path);
  43. return (-1);
  44. }
  45. --
  46. 2.37.3