mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-07 17:46:15 +00:00
tools: acrn-crashlog: remove unsafe apis from android_events.c
1. Refine strings operation. 2. Remove sscanf, sprintf and strlen. Tracked-On: #1254 Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
@@ -15,22 +15,23 @@
|
||||
* Get the length of line.
|
||||
*
|
||||
* @param str Start address of line.
|
||||
* @param size Size of searched space.
|
||||
*
|
||||
* @return the length of line if successful, or -1 if not.
|
||||
* This function return length of string if string doesn't contain \n.
|
||||
* @return the length of line (excludes \n) if successful, or -1 if not.
|
||||
* This function return -1 if string doesn't contain \n.
|
||||
*/
|
||||
int strlinelen(char *str)
|
||||
ssize_t strlinelen(const char *str, size_t size)
|
||||
{
|
||||
char *tag;
|
||||
char *tail;
|
||||
|
||||
if (!str)
|
||||
return -1;
|
||||
|
||||
tag = strchr(str, '\n');
|
||||
if (tag)
|
||||
return tag - str + 1;
|
||||
tail = memchr(str, '\n', size);
|
||||
if (tail)
|
||||
return tail - str;
|
||||
|
||||
return strlen(str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user