libiscsi-0004-examples-fix-uint64_t-formatting-issues.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From fdfeff0462e17e0f0e37e65e5b6be6e74a9b39fd Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Tue, 2 Sep 2014 22:43:44 +0200
  4. Subject: [PATCH 4/4] examples: fix uint64_t formatting issues
  5. Using %lu to format uint64_t doesn't work for 32 bits architecture,
  6. because uint64_t is an unsigned long long and therefore %llu should be
  7. used. The solution is to use PRIu64 from <inttypes.h>, which is equal
  8. to %lu on 64 bits architectures, and %llu on 32 bits architectures,
  9. which corresponds to the definition of uint64_t.
  10. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  11. ---
  12. examples/iscsi-dd.c | 5 +++--
  13. 1 file changed, 3 insertions(+), 2 deletions(-)
  14. diff --git a/examples/iscsi-dd.c b/examples/iscsi-dd.c
  15. index 4cc7c2b..33007c3 100644
  16. --- a/examples/iscsi-dd.c
  17. +++ b/examples/iscsi-dd.c
  18. @@ -19,6 +19,7 @@
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <string.h>
  22. +#include <inttypes.h>
  23. #include <poll.h>
  24. #include <getopt.h>
  25. #include "iscsi.h"
  26. @@ -79,7 +80,7 @@ void write_cb(struct iscsi_context *iscsi, int status, void *command_data, void
  27. fill_read_queue(client);
  28. if (client->progress) {
  29. - printf("\r%lu of %lu blocks transferred.", client->pos, client->src_num_blocks);
  30. + printf("\r%" PRIu64 " of %" PRIu64 " blocks transferred.", client->pos, client->src_num_blocks);
  31. }
  32. if ((client->in_flight == 0) && (client->pos == client->src_num_blocks)) {
  33. @@ -378,7 +379,7 @@ int main(int argc, char *argv[])
  34. }
  35. if (client.src_num_blocks > client.dst_num_blocks) {
  36. - fprintf(stderr, "source LUN is bigger than destination (%lu > %lu sectors)\n", client.src_num_blocks, client.dst_num_blocks);
  37. + fprintf(stderr, "source LUN is bigger than destination (%" PRIu64 " > %" PRIu64 " sectors)\n", client.src_num_blocks, client.dst_num_blocks);
  38. exit(10);
  39. }
  40. --
  41. 2.0.0