0001-lib-hsh.c-rename-hsh-local-variable.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 591fc6da944ffc29936e0019b2bc225ddc81dbba Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Mon, 20 Nov 2017 22:48:33 +0100
  4. Subject: [PATCH] lib/hsh.c: rename hsh local variable
  5. The hsh local variable name conflicts with the function prototype of
  6. hsh() in hsh.h, causing the following build issues with old compilers
  7. (gcc 4.7):
  8. hsh.c: In function 'hsh':
  9. hsh.c:28:21: error: declaration of 'hsh' shadows a global declaration [-Werror=shadow]
  10. hsh.c:26:1: error: shadowed declaration is here [-Werror=shadow]
  11. hsh.c: In function 'hsh_buf':
  12. hsh.c:60:21: error: declaration of 'hsh' shadows a global declaration [-Werror=shadow]
  13. hsh.c:26:1: error: shadowed declaration is here [-Werror=shadow]
  14. Therefore, we rename this local variable to _hsh.
  15. Submitted-upstream: https://github.com/latchset/jose/pull/51
  16. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  17. ---
  18. lib/hsh.c | 12 ++++++------
  19. 1 file changed, 6 insertions(+), 6 deletions(-)
  20. diff --git a/lib/hsh.c b/lib/hsh.c
  21. index c59a95f..a2a891b 100644
  22. --- a/lib/hsh.c
  23. +++ b/lib/hsh.c
  24. @@ -25,7 +25,7 @@
  25. json_t *
  26. hsh(jose_cfg_t *cfg, const char *alg, const void *data, size_t dlen)
  27. {
  28. - jose_io_auto_t *hsh = NULL;
  29. + jose_io_auto_t *_hsh = NULL;
  30. jose_io_auto_t *enc = NULL;
  31. jose_io_auto_t *buf = NULL;
  32. char b[1024] = {};
  33. @@ -33,8 +33,8 @@ hsh(jose_cfg_t *cfg, const char *alg, const void *data, size_t dlen)
  34. buf = jose_io_buffer(cfg, b, &l);
  35. enc = jose_b64_enc_io(buf);
  36. - hsh = hsh_io(cfg, alg, enc);
  37. - if (!buf || !enc || !hsh || !hsh->feed(hsh, data, dlen) || !hsh->done(hsh))
  38. + _hsh = hsh_io(cfg, alg, enc);
  39. + if (!buf || !enc || !_hsh || !_hsh->feed(_hsh, data, dlen) || !_hsh->done(_hsh))
  40. return NULL;
  41. return json_stringn(b, l);
  42. @@ -57,7 +57,7 @@ hsh_buf(jose_cfg_t *cfg, const char *alg,
  43. const void *data, size_t dlen, void *hash, size_t hlen)
  44. {
  45. const jose_hook_alg_t *a = NULL;
  46. - jose_io_auto_t *hsh = NULL;
  47. + jose_io_auto_t *_hsh = NULL;
  48. jose_io_auto_t *buf = NULL;
  49. a = jose_hook_alg_find(JOSE_HOOK_ALG_KIND_HASH, alg);
  50. @@ -71,8 +71,8 @@ hsh_buf(jose_cfg_t *cfg, const char *alg,
  51. return SIZE_MAX;
  52. buf = jose_io_buffer(cfg, hash, &hlen);
  53. - hsh = a->hash.hsh(a, cfg, buf);
  54. - if (!buf || !hsh || !hsh->feed(hsh, data, dlen) || !hsh->done(hsh))
  55. + _hsh = a->hash.hsh(a, cfg, buf);
  56. + if (!buf || !_hsh || !_hsh->feed(_hsh, data, dlen) || !_hsh->done(_hsh))
  57. return SIZE_MAX;
  58. return hlen;
  59. --
  60. 2.13.6