Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions util/include/rusefi/efistring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <cstddef>

char *strlncpy(char *dest, const char *src, size_t size);
17 changes: 17 additions & 0 deletions util/src/efistring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <rusefi/efistring.h>

// see strncpy man page
// this implementation helps avoiding following gcc error/warning:
// error: 'strncpy' output may be truncated copying xxx bytes from a string of length xxx

char *strlncpy(char *dest, const char *src, size_t size)
{
size_t i;

for (i = 0; (i < (size - 1)) && (src[i] != '\0'); i++)
dest[i] = src[i];
for ( ; i < size; i++)
dest[i] = '\0';

return dest;
}
1 change: 1 addition & 0 deletions util/util.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ RUSEFI_LIB_INC += $(RUSEFI_LIB)/util/include $(RUSEFI_LIB)/util/include/rusefi/c
RUSEFI_LIB_CPP += \
$(RUSEFI_LIB)/util/src/util_dummy.cpp \
$(RUSEFI_LIB)/util/src/crc.cpp \
$(RUSEFI_LIB)/util/src/efistring.cpp \
$(RUSEFI_LIB)/util/src/efistringutil.cpp \
$(RUSEFI_LIB)/util/src/fragments.cpp \
$(RUSEFI_LIB)/util/src/rusefi_math.cpp \
Expand Down
Loading