mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
bafdf4caac
On request/suggestion from Simon Glass back in May 22 2019 [1], the 'strsep' mechanism implemented in bcb_set() was set to work directly with user-provided argv strings, to avoid duplicating memory and for the sake of simpler implementation. However, since we recently exposed bcb_write_reboot_reason() API to be called by U-Boot fastboot, the idea is to be able to pass const string literals to this new BCB API, carrying the reboot reason. Since 'strsep' (just like its older/superseded sibling 'strtok') modifies the input string passed as parameter, BCB command in its current state would attempt to perform in-place modifications in a readonly string, which might lead to unexpected results. Fix the above with the cost of one dynamic memory allocation ('strdup'). This will also ensure no compiler warnings when passing string literals to bcb_write_reboot_reason(). [1] http://u-boot.10912.n7.nabble.com/PATCH-v2-0-2-Add-bcb-command-to-read-modify-write-Android-BCB-td369934i20.html#a370456 Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
21 lines
471 B
C
21 lines
471 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2020 Eugeniu Rosca <rosca.eugeniu@gmail.com>
|
|
*
|
|
* Android Bootloader Control Block Header
|
|
*/
|
|
|
|
#ifndef __BCB_H__
|
|
#define __BCB_H__
|
|
|
|
#if CONFIG_IS_ENABLED(CMD_BCB)
|
|
int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp);
|
|
#else
|
|
#include <linux/errno.h>
|
|
static inline int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
#endif
|
|
|
|
#endif /* __BCB_H__ */
|