Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
55ac1f30
Commit
55ac1f30
authored
2 years ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
Fix some type conversions
parent
7007fc9f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Binary output
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/cmp_io.c
+10
-10
10 additions, 10 deletions
lib/cmp_io.c
with
10 additions
and
10 deletions
lib/cmp_io.c
+
10
−
10
View file @
55ac1f30
...
@@ -1144,7 +1144,7 @@ static __inline const char *skip_comment(const char *str)
...
@@ -1144,7 +1144,7 @@ static __inline const char *skip_comment(const char *str)
* conversion can be performed, 0 is returned (errno is set to EINVAL)).
* conversion can be performed, 0 is returned (errno is set to EINVAL)).
*/
*/
static
__inline
uint8_t
str_to_uint8
(
const
char
*
str
,
char
**
str_end
)
static
__inline
uint8_t
str_to_uint8
(
const
char
*
str
,
char
const
**
str_end
)
{
{
const
int
BASE
=
16
;
const
int
BASE
=
16
;
int
i
;
int
i
;
...
@@ -1156,7 +1156,7 @@ static __inline uint8_t str_to_uint8(const char *str, char **str_end)
...
@@ -1156,7 +1156,7 @@ static __inline uint8_t str_to_uint8(const char *str, char **str_end)
orig
=
str
;
orig
=
str
;
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
i
=
0
;
i
<
2
;
i
++
)
{
unsigned
char
c
=
*
str
;
unsigned
char
c
=
(
unsigned
char
)
*
str
;
if
(
c
>=
'a'
)
if
(
c
>=
'a'
)
c
=
c
-
'a'
+
10
;
c
=
c
-
'a'
+
10
;
...
@@ -1176,7 +1176,7 @@ static __inline uint8_t str_to_uint8(const char *str, char **str_end)
...
@@ -1176,7 +1176,7 @@ static __inline uint8_t str_to_uint8(const char *str, char **str_end)
}
}
if
(
str_end
)
if
(
str_end
)
*
str_end
=
(
char
*
)
str
;
*
str_end
=
str
;
if
(
unlikely
(
str
==
orig
))
{
/* no value read in */
if
(
unlikely
(
str
==
orig
))
{
/* no value read in */
errno
=
EINVAL
;
errno
=
EINVAL
;
...
@@ -1212,20 +1212,20 @@ static ssize_t __inline str2uint8_arr(const char *str, uint8_t *data, uint32_t b
...
@@ -1212,20 +1212,20 @@ static ssize_t __inline str2uint8_arr(const char *str, uint8_t *data, uint32_t b
const
char
*
file_name
,
int
verbose_en
)
const
char
*
file_name
,
int
verbose_en
)
{
{
const
char
*
nptr
=
str
;
const
char
*
nptr
=
str
;
char
*
eptr
=
NULL
;
const
char
*
eptr
=
NULL
;
size_t
i
=
0
;
size_t
i
=
0
;
errno
=
0
;
errno
=
0
;
if
(
!
data
)
if
(
!
data
)
buf_size
=
~
0
;
buf_size
=
~
0
U
;
if
(
!
file_name
)
if
(
!
file_name
)
file_name
=
"unknown file name"
;
file_name
=
"unknown file name"
;
for
(
i
=
0
;
i
<
buf_size
;
)
{
for
(
i
=
0
;
i
<
buf_size
;
)
{
uint8_t
read_val
;
uint8_t
read_val
;
unsigned
char
c
=
*
nptr
;
char
c
=
*
nptr
;
if
(
c
==
'\0'
)
{
if
(
c
==
'\0'
)
{
if
(
!
data
)
/* finished counting the sample */
if
(
!
data
)
/* finished counting the sample */
...
@@ -1292,7 +1292,7 @@ static ssize_t __inline str2uint8_arr(const char *str, uint8_t *data, uint32_t b
...
@@ -1292,7 +1292,7 @@ static ssize_t __inline str2uint8_arr(const char *str, uint8_t *data, uint32_t b
PROGRAM_NAME
,
file_name
);
PROGRAM_NAME
,
file_name
);
}
}
return
i
;
return
(
ssize_t
)
i
;
}
}
...
@@ -1365,7 +1365,7 @@ ssize_t read_file8(const char *file_name, uint8_t *buf, uint32_t buf_size, int f
...
@@ -1365,7 +1365,7 @@ ssize_t read_file8(const char *file_name, uint8_t *buf, uint32_t buf_size, int f
return
file_size
;
return
file_size
;
}
}
file_cpy
=
(
char
*
)
calloc
((
size_t
)
file_size
+
1
,
sizeof
(
uint8_t
));
file_cpy
=
calloc
((
size_t
)
file_size
+
1
,
sizeof
(
char
));
if
(
file_cpy
==
NULL
)
{
if
(
file_cpy
==
NULL
)
{
fprintf
(
stderr
,
"%s: %s: Error: allocating memory!
\n
"
,
PROGRAM_NAME
,
file_name
);
fprintf
(
stderr
,
"%s: %s: Error: allocating memory!
\n
"
,
PROGRAM_NAME
,
file_name
);
goto
fail
;
goto
fail
;
...
@@ -1551,7 +1551,7 @@ uint32_t cmp_tool_gen_version_id(const char *version)
...
@@ -1551,7 +1551,7 @@ uint32_t cmp_tool_gen_version_id(const char *version)
*/
*/
copy
=
strdup
(
version
);
copy
=
strdup
(
version
);
token
=
strtok
(
copy
,
"."
);
token
=
strtok
(
copy
,
"."
);
n
=
atoi
(
token
);
n
=
(
unsigned
int
)
atoi
(
token
);
if
(
n
>
UINT16_MAX
)
{
if
(
n
>
UINT16_MAX
)
{
free
(
copy
);
free
(
copy
);
return
0
;
return
0
;
...
@@ -1563,7 +1563,7 @@ uint32_t cmp_tool_gen_version_id(const char *version)
...
@@ -1563,7 +1563,7 @@ uint32_t cmp_tool_gen_version_id(const char *version)
}
}
token
=
strtok
(
NULL
,
"."
);
token
=
strtok
(
NULL
,
"."
);
n
=
atoi
(
token
);
n
=
(
unsigned
int
)
atoi
(
token
);
free
(
copy
);
free
(
copy
);
if
(
n
>
UINT16_MAX
)
if
(
n
>
UINT16_MAX
)
return
0
;
return
0
;
...
...
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