Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
0f44398b
Commit
0f44398b
authored
Oct 29, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_safe_long()
Signed-off-by:
Christian Brauner
<
christian.brauner@canonical.com
>
parent
c453697f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
utils.c
src/lxc/utils.c
+21
-1
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
0f44398b
...
@@ -2007,7 +2007,7 @@ int lxc_safe_uint(const char *numstr, unsigned int *converted)
...
@@ -2007,7 +2007,7 @@ int lxc_safe_uint(const char *numstr, unsigned int *converted)
if
(
uli
>
UINT_MAX
)
if
(
uli
>
UINT_MAX
)
return
-
ERANGE
;
return
-
ERANGE
;
*
converted
=
(
unsigned
)
uli
;
*
converted
=
(
unsigned
int
)
uli
;
return
0
;
return
0
;
}
}
...
@@ -2030,3 +2030,23 @@ int lxc_safe_int(const char *numstr, int *converted)
...
@@ -2030,3 +2030,23 @@ int lxc_safe_int(const char *numstr, int *converted)
*
converted
=
(
int
)
sli
;
*
converted
=
(
int
)
sli
;
return
0
;
return
0
;
}
}
int
lxc_safe_long
(
const
char
*
numstr
,
long
int
*
converted
)
{
char
*
err
=
NULL
;
signed
long
int
sli
;
errno
=
0
;
sli
=
strtol
(
numstr
,
&
err
,
0
);
if
(
errno
>
0
)
return
-
errno
;
if
(
!
err
||
err
==
numstr
||
*
err
!=
'\0'
)
return
-
EINVAL
;
if
(
sli
>
LONG_MAX
)
return
-
ERANGE
;
*
converted
=
sli
;
return
0
;
}
src/lxc/utils.h
View file @
0f44398b
...
@@ -320,5 +320,6 @@ bool task_blocking_signal(pid_t pid, int signal);
...
@@ -320,5 +320,6 @@ bool task_blocking_signal(pid_t pid, int signal);
/* Helper functions to parse numbers. */
/* Helper functions to parse numbers. */
int
lxc_safe_uint
(
const
char
*
numstr
,
unsigned
int
*
converted
);
int
lxc_safe_uint
(
const
char
*
numstr
,
unsigned
int
*
converted
);
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
);
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
);
int
lxc_safe_long
(
const
char
*
numstr
,
long
int
*
converted
);
#endif
/* __LXC_UTILS_H */
#endif
/* __LXC_UTILS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment