acrn-hypervisor/devicemodel/lib/dm_string.c
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00

63 lines
1.0 KiB
C

/*
* Copyright (C) 2018 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "dm_string.h"
int
dm_strtol(const char *s, char **end, unsigned int base, long *val)
{
if (!s)
return -1;
*val = strtol(s, end, base);
if ((end && *end == s) || errno == ERANGE)
return -1;
return 0;
}
int
dm_strtoi(const char *s, char **end, unsigned int base, int *val)
{
long l_val;
int ret;
l_val = 0;
ret = dm_strtol(s, end, base, &l_val);
if (ret == 0)
*val = (int)l_val;
return ret;
}
int
dm_strtoul(const char *s, char **end, unsigned int base, unsigned long *val)
{
if (!s)
return -1;
*val = strtoul(s, end, base);
if ((end && *end == s) || errno == ERANGE)
return -1;
return 0;
}
int
dm_strtoui(const char *s, char **end, unsigned int base, unsigned int *val)
{
unsigned long l_val;
int ret;
l_val = 0;
ret = dm_strtoul(s, end, base, &l_val);
if (ret == 0)
*val = (unsigned int)l_val;
return ret;
}