Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Packetdrill_tarr_ext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Gense
Packetdrill_tarr_ext
Commits
dec3b242
Commit
dec3b242
authored
9 years ago
by
Michael Tüxen
Browse files
Options
Downloads
Patches
Plain Diff
Use appropriate constants for range check.
parent
fdca75bc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gtests/net/packetdrill/run_system_call.c
+21
-21
21 additions, 21 deletions
gtests/net/packetdrill/run_system_call.c
with
21 additions
and
21 deletions
gtests/net/packetdrill/run_system_call.c
+
21
−
21
View file @
dec3b242
...
@@ -181,18 +181,18 @@ static int check_type(struct expression *expression,
...
@@ -181,18 +181,18 @@ static int check_type(struct expression *expression,
}
}
/* Sets the value from the expression argument, checking that it is a
/* Sets the value from the expression argument, checking that it is a
* valid u
16
, and matches the expected type. Returns STATUS_OK on
* valid u
32
, and matches the expected type. Returns STATUS_OK on
* success; on failure returns STATUS_ERR and sets error message.
* success; on failure returns STATUS_ERR and sets error message.
*/
*/
static
int
get_u
16
(
struct
expression
*
expression
,
static
int
get_u
32
(
struct
expression
*
expression
,
u
16
*
value
,
char
**
error
)
u
32
*
value
,
char
**
error
)
{
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
((
expression
->
value
.
num
>
UINT
16
_MAX
)
||
if
((
expression
->
value
.
num
>
UINT
32
_MAX
)
||
(
expression
->
value
.
num
<
0
))
{
(
expression
->
value
.
num
<
0
))
{
asprintf
(
error
,
asprintf
(
error
,
"Value out of range for
16
-bit unsigned integer: %lld"
,
"Value out of range for
32
-bit unsigned integer: %lld"
,
expression
->
value
.
num
);
expression
->
value
.
num
);
return
STATUS_ERR
;
return
STATUS_ERR
;
}
}
...
@@ -201,18 +201,18 @@ static int get_u16(struct expression *expression,
...
@@ -201,18 +201,18 @@ static int get_u16(struct expression *expression,
}
}
/* Sets the value from the expression argument, checking that it is a
/* Sets the value from the expression argument, checking that it is a
* valid u32, and matches the expected type. Returns STATUS_OK on
* valid
s32 or
u32, and matches the expected type. Returns STATUS_OK on
* success; on failure returns STATUS_ERR and sets error message.
* success; on failure returns STATUS_ERR and sets error message.
*/
*/
static
int
get_
u
32
(
struct
expression
*
expression
,
static
int
get_
s
32
(
struct
expression
*
expression
,
u
32
*
value
,
char
**
error
)
s
32
*
value
,
char
**
error
)
{
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
((
expression
->
value
.
num
>
UINT
32
_MAX
)
||
if
((
expression
->
value
.
num
>
UINT_MAX
)
||
(
expression
->
value
.
num
<
0
))
{
(
expression
->
value
.
num
<
INT_MIN
))
{
asprintf
(
error
,
asprintf
(
error
,
"Value out of range for 32-bit
unsigned
integer: %lld"
,
"Value out of range for 32-bit integer: %lld"
,
expression
->
value
.
num
);
expression
->
value
.
num
);
return
STATUS_ERR
;
return
STATUS_ERR
;
}
}
...
@@ -221,18 +221,18 @@ static int get_u32(struct expression *expression,
...
@@ -221,18 +221,18 @@ static int get_u32(struct expression *expression,
}
}
/* Sets the value from the expression argument, checking that it is a
/* Sets the value from the expression argument, checking that it is a
* valid
s32 or u32
, and matches the expected type. Returns STATUS_OK on
* valid
u16
, and matches the expected type. Returns STATUS_OK on
* success; on failure returns STATUS_ERR and sets error message.
* success; on failure returns STATUS_ERR and sets error message.
*/
*/
static
int
get_
s32
(
struct
expression
*
expression
,
static
int
get_
u16
(
struct
expression
*
expression
,
s32
*
value
,
char
**
error
)
u16
*
value
,
char
**
error
)
{
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
((
expression
->
value
.
num
>
UINT_MAX
)
||
if
((
expression
->
value
.
num
>
UINT
16
_MAX
)
||
(
expression
->
value
.
num
<
INT_MIN
))
{
(
expression
->
value
.
num
<
0
))
{
asprintf
(
error
,
asprintf
(
error
,
"Value out of range for
32
-bit integer: %lld"
,
"Value out of range for
16
-bit
unsigned
integer: %lld"
,
expression
->
value
.
num
);
expression
->
value
.
num
);
return
STATUS_ERR
;
return
STATUS_ERR
;
}
}
...
@@ -249,8 +249,8 @@ static int get_s16(struct expression *expression,
...
@@ -249,8 +249,8 @@ static int get_s16(struct expression *expression,
{
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
((
expression
->
value
.
num
>
USHRT
_MAX
)
||
if
((
expression
->
value
.
num
>
INT16
_MAX
)
||
(
expression
->
value
.
num
<
SHRT
_MIN
))
{
(
expression
->
value
.
num
<
INT16
_MIN
))
{
asprintf
(
error
,
asprintf
(
error
,
"Value out of range for 16-bit integer: %lld"
,
"Value out of range for 16-bit integer: %lld"
,
expression
->
value
.
num
);
expression
->
value
.
num
);
...
@@ -269,8 +269,8 @@ static int get_s8(struct expression *expression,
...
@@ -269,8 +269,8 @@ static int get_s8(struct expression *expression,
{
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
((
expression
->
value
.
num
>
UCHAR
_MAX
)
||
if
((
expression
->
value
.
num
>
INT8
_MAX
)
||
(
expression
->
value
.
num
<
SCHAR
_MIN
))
{
(
expression
->
value
.
num
<
INT8
_MIN
))
{
asprintf
(
error
,
asprintf
(
error
,
"Value out of range for 8-bit integer: %lld"
,
"Value out of range for 8-bit integer: %lld"
,
expression
->
value
.
num
);
expression
->
value
.
num
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment