Hi,
On 2018-05-25 14:00, [ext] Andreas J. Reichel wrote:
From: Andreas Reichel <[email protected]>
To compare device paths it is necessary to be able to split of
sub-paths from the right hand side. Implement a simple function
for that purpose.
Signed-off-by: Andreas Reichel <[email protected]>
---
include/utils.h | 1 +
utils.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/utils.h b/include/utils.h
index 285e45e..06721eb 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -29,6 +29,7 @@ typedef struct _VOLUME_DESC {
typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;
+CHAR16 *StrRStrip(CHAR16 *input, CHAR16 delim);
uint32_t calc_crc32(void *data, int32_t size);
void __noreturn error_exit(CHAR16 *message, EFI_STATUS status);
VOID sleep(int32_t sec);
diff --git a/utils.c b/utils.c
index 33e3a90..4f44a37 100644
--- a/utils.c
+++ b/utils.c
@@ -16,6 +16,29 @@
#include <bootguard.h>
#include <utils.h>
+CHAR16 *StrRStrip(CHAR16 *input, CHAR16 delim)
+{
+ CHAR16 *dst;
+ UINTN len;
+
+ len = StrLen(input);
+ dst = mmalloc((len + 1) * 2);
Magic numbers. Use 'sizeof'.
+ if (!dst) {
+ return NULL;
+ }
+
+ StrCpy(dst, input);
+
+ for (UINTN i = len; i > 0; i--)
+ {
+ if (dst[i * 2] == delim) {
+ dst[i * 2] = L'\0';
+ break;
+ }
+ }
Here I get this itching in my coding fingers. I would try do copying and
striping in one loop.
Claudius
+ return dst;
+}
+
uint32_t calc_crc32(void *data, int32_t size)
{
uint32_t crc;
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: [email protected]
--
You received this message because you are subscribed to the Google Groups "EFI Boot
Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/0b4bcda1-3617-c58c-542a-494bc72a28ad%40siemens.com.
For more options, visit https://groups.google.com/d/optout.