efi_selftest_util.c 580 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * efi_selftest_util
  4. *
  5. * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
  6. *
  7. * Utility functions
  8. */
  9. #include <efi_selftest.h>
  10. int efi_st_memcmp(const void *buf1, const void *buf2, size_t length)
  11. {
  12. const u8 *pos1 = buf1;
  13. const u8 *pos2 = buf2;
  14. for (; length; --length) {
  15. if (*pos1 != *pos2)
  16. return *pos1 - *pos2;
  17. ++pos1;
  18. ++pos2;
  19. }
  20. return 0;
  21. }
  22. int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2)
  23. {
  24. for (; *buf1 || *buf2; ++buf1, ++buf2) {
  25. if (*buf1 != *buf2)
  26. return *buf1 - *buf2;
  27. }
  28. return 0;
  29. }