Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
a4f8e94b
Commit
a4f8e94b
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of alloca() in compiler
parent
e2bbbf8f
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
76 additions
and
91 deletions
+76
-91
asn1c/asn1c.c
asn1c/asn1c.c
+5
-5
asn1c/sys-common.h
asn1c/sys-common.h
+0
-3
configure.ac
configure.ac
+1
-2
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+4
-1
libasn1compiler/asn1c_compat.c
libasn1compiler/asn1c_compat.c
+11
-15
libasn1compiler/asn1c_compat.h
libasn1compiler/asn1c_compat.h
+2
-2
libasn1compiler/asn1c_fdeps.c
libasn1compiler/asn1c_fdeps.c
+9
-4
libasn1compiler/asn1c_internal.h
libasn1compiler/asn1c_internal.h
+0
-4
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+4
-5
tests/tests-c-compiler/check-src/check-22.-fwide-types.c
tests/tests-c-compiler/check-src/check-22.-fwide-types.c
+2
-5
tests/tests-c-compiler/check-src/check-24.-fwide-types.c
tests/tests-c-compiler/check-src/check-24.-fwide-types.c
+2
-5
tests/tests-c-compiler/check-src/check-25.-fwide-types.c
tests/tests-c-compiler/check-src/check-25.-fwide-types.c
+7
-11
tests/tests-c-compiler/check-src/check-30.-fwide-types.c
tests/tests-c-compiler/check-src/check-30.-fwide-types.c
+2
-5
tests/tests-c-compiler/check-src/check-31.-fwide-types.c
tests/tests-c-compiler/check-src/check-31.-fwide-types.c
+2
-5
tests/tests-c-compiler/check-src/check-35.c
tests/tests-c-compiler/check-src/check-35.c
+5
-4
tests/tests-c-compiler/check-src/check-41.-fwide-types.c
tests/tests-c-compiler/check-src/check-41.-fwide-types.c
+9
-7
tests/tests-c-compiler/check-src/check-41.c
tests/tests-c-compiler/check-src/check-41.c
+9
-7
tests/tests-c-compiler/check-src/check-42.c
tests/tests-c-compiler/check-src/check-42.c
+2
-1
No files found.
asn1c/asn1c.c
View file @
a4f8e94b
...
@@ -226,7 +226,7 @@ main(int ac, char **av) {
...
@@ -226,7 +226,7 @@ main(int ac, char **av) {
ac
-=
optind
;
ac
-=
optind
;
av
+=
optind
;
av
+=
optind
;
}
else
{
}
else
{
char
*
bin_name
=
a1c_basename
(
av
[
0
]);
c
onst
c
har
*
bin_name
=
a1c_basename
(
av
[
0
]);
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: No input files specified. "
"%s: No input files specified. "
"Try '%s -h' for more information
\n
"
,
"Try '%s -h' for more information
\n
"
,
...
@@ -247,15 +247,15 @@ main(int ac, char **av) {
...
@@ -247,15 +247,15 @@ main(int ac, char **av) {
* compute it from my file name:
* compute it from my file name:
* ./asn1c/asn1c -> ./skeletons
* ./asn1c/asn1c -> ./skeletons
*/
*/
c
har
*
p
;
c
onst
char
*
skel_dir
;
size_t
len
;
size_t
len
;
p
=
a1c_dirname
(
av
[
-
optind
]);
skel_dir
=
a1c_dirname
(
av
[
-
optind
]);
len
=
strlen
(
p
)
+
sizeof
(
"/../skeletons"
);
len
=
strlen
(
skel_dir
)
+
sizeof
(
"/../skeletons"
);
skeletons_dir
=
malloc
(
len
);
skeletons_dir
=
malloc
(
len
);
assert
(
skeletons_dir
);
assert
(
skeletons_dir
);
snprintf
(
skeletons_dir
,
len
,
"%s/../skeletons"
,
p
);
snprintf
(
skeletons_dir
,
len
,
"%s/../skeletons"
,
skel_dir
);
if
(
stat
(
skeletons_dir
,
&
sb
))
{
if
(
stat
(
skeletons_dir
,
&
sb
))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"WARNING: skeletons are neither in "
"WARNING: skeletons are neither in "
...
...
This diff is collapsed.
Click to expand it.
asn1c/sys-common.h
View file @
a4f8e94b
...
@@ -64,8 +64,5 @@
...
@@ -64,8 +64,5 @@
#ifndef EX_OSFILE
#ifndef EX_OSFILE
#define EX_OSFILE 72
#define EX_OSFILE 72
#endif
#endif
#if defined HAVE_DECL_ALLOCA && !HAVE_DECL_ALLOCA
#define alloca _alloca
#endif
#define snprintf _snprintf
#define snprintf _snprintf
#endif
/* _WIN32 */
#endif
/* _WIN32 */
This diff is collapsed.
Click to expand it.
configure.ac
View file @
a4f8e94b
...
@@ -227,7 +227,6 @@ AC_SUBST(ASAN_ENV_FLAGS)
...
@@ -227,7 +227,6 @@ AC_SUBST(ASAN_ENV_FLAGS)
dnl Checks for header files.
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(alloca.h)
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN
AC_C_BIGENDIAN
...
@@ -249,7 +248,7 @@ AC_CHECK_FUNCS(strtoimax strtoll)
...
@@ -249,7 +248,7 @@ AC_CHECK_FUNCS(strtoimax strtoll)
AC_CHECK_FUNCS(mergesort)
AC_CHECK_FUNCS(mergesort)
AC_CHECK_FUNCS(mkstemps)
AC_CHECK_FUNCS(mkstemps)
AC_CHECK_FUNCS(timegm)
AC_CHECK_FUNCS(timegm)
AC_CHECK_DECLS(
alloca
strcasecmp)
AC_CHECK_DECLS(strcasecmp)
AC_CHECK_DECLS(vasprintf)
AC_CHECK_DECLS(vasprintf)
AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])])
AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])])
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_C.c
View file @
a4f8e94b
...
@@ -132,7 +132,8 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -132,7 +132,8 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
int
eidx
;
int
eidx
;
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
v2e
=
alloca
((
el_count
+
1
)
*
sizeof
(
*
v2e
));
v2e
=
calloc
(
el_count
+
1
,
sizeof
(
*
v2e
));
assert
(
v2e
);
/*
/*
* For all ENUMERATED types and for those INTEGER types which
* For all ENUMERATED types and for those INTEGER types which
...
@@ -162,6 +163,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -162,6 +163,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
map_extensions
=
eidx
+
1
;
map_extensions
=
eidx
+
1
;
break
;
break
;
default:
default:
free
(
v2e
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -258,6 +260,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -258,6 +260,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
REDIR
(
saved_target
);
REDIR
(
saved_target
);
free
(
v2e
);
return
asn1c_lang_C_type_SIMPLE_TYPE
(
arg
);
return
asn1c_lang_C_type_SIMPLE_TYPE
(
arg
);
}
}
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_compat.c
View file @
a4f8e94b
#include "asn1c_internal.h"
#include "asn1c_internal.h"
#include "asn1c_compat.h"
#include "asn1c_compat.h"
#ifndef
MAXPATHLEN
#ifndef
PATH_MAX
#define
MAXPATHLEN
1024
#define
PATH_MAX
1024
#endif
#endif
/* Normally file permissions are (DEFFILEMODE & ~umask(2)) */
/* Normally file permissions are (DEFFILEMODE & ~umask(2)) */
...
@@ -41,12 +41,11 @@ int mkstemp(char *template) {
...
@@ -41,12 +41,11 @@ int mkstemp(char *template) {
FILE
*
FILE
*
asn1c_open_file
(
const
char
*
name
,
const
char
*
ext
,
char
**
opt_tmpname
)
{
asn1c_open_file
(
const
char
*
name
,
const
char
*
ext
,
char
**
opt_tmpname
)
{
char
fname
[
PATH_MAX
];
int
created
=
1
;
int
created
=
1
;
#ifndef _WIN32
#ifndef _WIN32
struct
stat
sb
;
struct
stat
sb
;
#endif
#endif
char
*
fname
;
size_t
len
;
FILE
*
fp
;
FILE
*
fp
;
int
ret
;
int
ret
;
int
fd
;
int
fd
;
...
@@ -54,13 +53,11 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
...
@@ -54,13 +53,11 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
/*
/*
* Compute filenames.
* Compute filenames.
*/
*/
len
=
strlen
(
name
)
+
strlen
(
ext
)
+
sizeof
(
".XXXXXX"
);
ret
=
snprintf
(
fname
,
sizeof
(
fname
),
"%s%s%s"
,
name
,
ext
,
fname
=
alloca
(
len
);
opt_tmpname
?
".XXXXXX"
:
""
);
ret
=
snprintf
(
fname
,
len
,
"%s%s%s"
,
name
,
ext
,
assert
(
ret
>
0
&&
ret
<
(
ssize_t
)
sizeof
(
fname
));
opt_tmpname
?
".XXXXXX"
:
""
);
assert
(
ret
>
0
&&
ret
<
(
ssize_t
)
len
);
if
(
opt_tmpname
)
{
if
(
opt_tmpname
)
{
/*
/*
* Create temporary file.
* Create temporary file.
*/
*/
...
@@ -130,10 +127,9 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
...
@@ -130,10 +127,9 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
return
fp
;
return
fp
;
}
}
const
char
*
char
*
a1c_basename
(
const
char
*
path
)
{
a1c_basename
(
const
char
*
path
)
{
static
char
strbuf
[
MAXPATHLEN
];
static
char
strbuf
[
PATH_MAX
];
const
char
*
pend
;
const
char
*
pend
;
const
char
*
name
;
const
char
*
name
;
...
@@ -165,9 +161,9 @@ a1c_basename(const char *path) {
...
@@ -165,9 +161,9 @@ a1c_basename(const char *path) {
}
}
char
*
c
onst
c
har
*
a1c_dirname
(
const
char
*
path
)
{
a1c_dirname
(
const
char
*
path
)
{
static
char
strbuf
[
MAXPATHLEN
];
static
char
strbuf
[
PATH_MAX
];
const
char
*
pend
;
const
char
*
pend
;
const
char
*
last
=
0
;
const
char
*
last
=
0
;
int
in_slash
=
0
;
int
in_slash
=
0
;
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_compat.h
View file @
a4f8e94b
...
@@ -14,7 +14,7 @@ FILE *asn1c_open_file(const char *base_part, const char *extension,
...
@@ -14,7 +14,7 @@ FILE *asn1c_open_file(const char *base_part, const char *extension,
* Obtain base name and directory name of a path.
* Obtain base name and directory name of a path.
* Some systems have them in <libgen.h> as dirname(3) and basename(3).
* Some systems have them in <libgen.h> as dirname(3) and basename(3).
*/
*/
char
*
a1c_basename
(
const
char
*
path
);
c
onst
c
har
*
a1c_basename
(
const
char
*
path
);
char
*
a1c_dirname
(
const
char
*
path
);
c
onst
c
har
*
a1c_dirname
(
const
char
*
path
);
#endif
/* ASN1C_COMPAT_H */
#endif
/* ASN1C_COMPAT_H */
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_fdeps.c
View file @
a4f8e94b
#include "asn1c_internal.h"
#include "asn1c_internal.h"
#include "asn1c_fdeps.h"
#include "asn1c_fdeps.h"
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
static
asn1c_fdeps_t
*
asn1c_new_dep
(
const
char
*
filename
);
static
asn1c_fdeps_t
*
asn1c_new_dep
(
const
char
*
filename
);
static
int
asn1c_dep_add
(
asn1c_fdeps_t
*
deps
,
asn1c_fdeps_t
*
d
);
static
int
asn1c_dep_add
(
asn1c_fdeps_t
*
deps
,
asn1c_fdeps_t
*
d
);
int
int
asn1c_activate_dependency
(
asn1c_fdeps_t
*
deps
,
asn1c_fdeps_t
*
cur
,
const
char
*
data
)
{
asn1c_activate_dependency
(
asn1c_fdeps_t
*
deps
,
asn1c_fdeps_t
*
cur
,
const
char
*
data
)
{
char
fname_scratch
[
PATH_MAX
];
const
char
*
fname
;
const
char
*
fname
;
int
i
;
int
i
;
...
@@ -30,10 +35,10 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d
...
@@ -30,10 +35,10 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d
end
=
strchr
(
start
,
'\"'
);
end
=
strchr
(
start
,
'\"'
);
}
}
if
(
end
)
{
if
(
end
)
{
char
*
p
=
alloca
((
end
-
start
)
+
1
);
assert
((
end
-
start
)
+
1
<
(
ssize_t
)
sizeof
(
fname_scratch
)
);
memcpy
(
p
,
start
,
end
-
start
);
memcpy
(
fname_scratch
,
start
,
end
-
start
);
p
[
end
-
start
]
=
'\0'
;
fname_scratch
[
end
-
start
]
=
'\0'
;
fname
=
p
;
fname
=
fname_scratch
;
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_internal.h
View file @
a4f8e94b
...
@@ -35,10 +35,6 @@
...
@@ -35,10 +35,6 @@
#endif
#endif
#include <fcntl.h>
/* for open(2) */
#include <fcntl.h>
/* for open(2) */
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
/* For MAXPATHLEN */
#endif
#include "asn1compiler.h"
#include "asn1compiler.h"
#include "asn1_namespace.h"
#include "asn1_namespace.h"
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_save.c
View file @
a4f8e94b
...
@@ -302,7 +302,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
...
@@ -302,7 +302,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
out_chunk_t
*
ot
;
out_chunk_t
*
ot
;
FILE
*
fp_c
,
*
fp_h
;
FILE
*
fp_c
,
*
fp_h
;
char
*
tmpname_c
,
*
tmpname_h
;
char
*
tmpname_c
,
*
tmpname_h
;
char
*
name_buf
;
char
name_buf
[
FILENAME_MAX
]
;
const
char
*
header_id
;
const
char
*
header_id
;
const
char
*
c_retained
=
""
;
const
char
*
c_retained
=
""
;
const
char
*
h_retained
=
""
;
const
char
*
h_retained
=
""
;
...
@@ -379,9 +379,9 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
...
@@ -379,9 +379,9 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
fclose
(
fp_c
);
fclose
(
fp_c
);
fclose
(
fp_h
);
fclose
(
fp_h
);
name_buf
=
alloca
(
strlen
(
filename
)
+
3
);
int
ret
=
snprintf
(
name_buf
,
sizeof
(
name_buf
),
"%s.c"
,
filename
);
assert
(
ret
>
0
&&
ret
<
(
ssize_t
)
sizeof
(
name_buf
));
sprintf
(
name_buf
,
"%s.c"
,
filename
);
if
(
identical_files
(
name_buf
,
tmpname_c
))
{
if
(
identical_files
(
name_buf
,
tmpname_c
))
{
c_retained
=
" (contents unchanged)"
;
c_retained
=
" (contents unchanged)"
;
unlink
(
tmpname_c
);
unlink
(
tmpname_c
);
...
@@ -521,14 +521,13 @@ real_copy(const char *src, const char *dst) {
...
@@ -521,14 +521,13 @@ real_copy(const char *src, const char *dst) {
static
int
static
int
asn1c_copy_over
(
arg_t
*
arg
,
char
*
path
)
{
asn1c_copy_over
(
arg_t
*
arg
,
char
*
path
)
{
char
*
fname
;
#ifdef _WIN32
#ifdef _WIN32
int
use_real_copy
=
1
;
int
use_real_copy
=
1
;
#else
#else
int
use_real_copy
=
!
(
arg
->
flags
&
A1C_LINK_SKELETONS
);
int
use_real_copy
=
!
(
arg
->
flags
&
A1C_LINK_SKELETONS
);
#endif
#endif
fname
=
a1c_basename
(
path
);
const
char
*
fname
=
a1c_basename
(
path
);
if
(
!
fname
if
(
!
fname
||
(
use_real_copy
?
real_copy
(
path
,
fname
)
:
symlink
(
path
,
fname
))
||
(
use_real_copy
?
real_copy
(
path
,
fname
)
:
symlink
(
path
,
fname
))
)
{
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-22.-fwide-types.c
View file @
a4f8e94b
...
@@ -117,14 +117,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -117,14 +117,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
static
void
static
void
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
uint8_t
*
tmp
;
uint8_t
tmp
[
size
];
int
i
;
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
tmp
=
alloca
(
size
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
int
loc
;
int
loc
;
memcpy
(
tmp
,
buf
,
size
);
memcpy
(
tmp
,
buf
,
size
);
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-24.-fwide-types.c
View file @
a4f8e94b
...
@@ -62,14 +62,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -62,14 +62,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
static
void
static
void
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
uint8_t
*
tmp
;
uint8_t
tmp
[
size
];
int
i
;
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
tmp
=
alloca
(
size
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
int
loc
;
int
loc
;
memcpy
(
tmp
,
buf
,
size
);
memcpy
(
tmp
,
buf
,
size
);
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-25.-fwide-types.c
View file @
a4f8e94b
...
@@ -141,14 +141,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -141,14 +141,11 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
static
void
static
void
try_corrupt
(
uint8_t
*
buf
,
size_t
size
,
int
allow_consume
)
{
try_corrupt
(
uint8_t
*
buf
,
size_t
size
,
int
allow_consume
)
{
uint8_t
*
tmp
;
uint8_t
tmp
[
size
];
int
i
;
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
tmp
=
alloca
(
size
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
int
loc
;
int
loc
;
memcpy
(
tmp
,
buf
,
size
);
memcpy
(
tmp
,
buf
,
size
);
...
@@ -173,10 +170,9 @@ static void
...
@@ -173,10 +170,9 @@ static void
partial_read
(
uint8_t
*
buf
,
size_t
size
)
{
partial_read
(
uint8_t
*
buf
,
size_t
size
)
{
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
uint8_t
tbuf1
[
size
];
uint8_t
*
tbuf1
=
alloca
(
size
);
uint8_t
tbuf2
[
size
];
uint8_t
*
tbuf2
=
alloca
(
size
);
uint8_t
tbuf3
[
size
];
uint8_t
*
tbuf3
=
alloca
(
size
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
...
@@ -186,8 +182,8 @@ partial_read(uint8_t *buf, size_t size) {
...
@@ -186,8 +182,8 @@ partial_read(uint8_t *buf, size_t size) {
* ^ buf ^ buf+size
* ^ buf ^ buf+size
* Try to read block by block.
* Try to read block by block.
*/
*/
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
size_t
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
for
(
size_t
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
buf
;
uint8_t
*
chunk1
=
buf
;
size_t
size1
=
i1
;
size_t
size1
=
i1
;
uint8_t
*
chunk2
=
buf
+
size1
;
uint8_t
*
chunk2
=
buf
+
size1
;
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-30.-fwide-types.c
View file @
a4f8e94b
...
@@ -216,14 +216,11 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
...
@@ -216,14 +216,11 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
static
void
static
void
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
uint8_t
*
tmp
;
uint8_t
tmp
[
size
];
int
i
;
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
tmp
=
alloca
(
size
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
int
loc
;
int
loc
;
memcpy
(
tmp
,
buf
,
size
);
memcpy
(
tmp
,
buf
,
size
);
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-31.-fwide-types.c
View file @
a4f8e94b
...
@@ -178,14 +178,11 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
...
@@ -178,14 +178,11 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
static
void
static
void
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
try_corrupt
(
uint8_t
*
buf
,
size_t
size
)
{
uint8_t
*
tmp
;
uint8_t
tmp
[
size
];
int
i
;
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
fprintf
(
stderr
,
"
\n
Corrupting...
\n
"
);
tmp
=
alloca
(
size
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
int
loc
;
int
loc
;
memcpy
(
tmp
,
buf
,
size
);
memcpy
(
tmp
,
buf
,
size
);
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-35.c
View file @
a4f8e94b
...
@@ -172,7 +172,8 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -172,7 +172,8 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
size_t
i
;
size_t
i
;
buf_size
=
cmp_buf_size
+
100
;
buf_size
=
cmp_buf_size
+
100
;
buf
=
alloca
(
buf_size
);
uint8_t
scratch
[
buf_size
];
buf
=
scratch
;
buf_pos
=
0
;
buf_pos
=
0
;
/*
/*
...
@@ -202,9 +203,9 @@ partial_read(uint8_t *data, size_t size) {
...
@@ -202,9 +203,9 @@ partial_read(uint8_t *data, size_t size) {
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
size_t
i1
,
i2
;
uint8_t
*
data1
=
alloca
(
size
)
;
uint8_t
data1
[
size
]
;
uint8_t
*
data2
=
alloca
(
size
)
;
uint8_t
data2
[
size
]
;
uint8_t
*
data3
=
alloca
(
size
)
;
uint8_t
data3
[
size
]
;
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-41.-fwide-types.c
View file @
a4f8e94b
...
@@ -188,7 +188,8 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -188,7 +188,8 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
size_t
i
;
size_t
i
;
buf_size
=
cmp_buf_size
+
100
;
buf_size
=
cmp_buf_size
+
100
;
buffer
=
alloca
(
buf_size
);
uint8_t
scratch
[
buf_size
];
buffer
=
scratch
;
buf_pos
=
0
;
buf_pos
=
0
;
/*
/*
...
@@ -211,16 +212,17 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -211,16 +212,17 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
}
}
assert
(
buffer
[
i
]
==
cmp_buf
[
i
]);
assert
(
buffer
[
i
]
==
cmp_buf
[
i
]);
}
}
buffer
=
0
;
}
}
static
void
static
void
partial_read
(
uint8_t
*
data
,
size_t
size
)
{
partial_read
(
uint8_t
*
data
,
size_t
size
)
{
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
uint8_t
data1
[
size
];
uint8_t
*
data1
=
alloca
(
size
);
uint8_t
data2
[
size
];
uint8_t
*
data2
=
alloca
(
size
);
uint8_t
data3
[
size
];
uint8_t
*
data3
=
alloca
(
size
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
...
@@ -230,8 +232,8 @@ partial_read(uint8_t *data, size_t size) {
...
@@ -230,8 +232,8 @@ partial_read(uint8_t *data, size_t size) {
* ^ data ^ data+size
* ^ data ^ data+size
* Try to read block by block.
* Try to read block by block.
*/
*/
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
size_t
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
for
(
size_t
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
data
;
uint8_t
*
chunk1
=
data
;
size_t
size1
=
i1
;
size_t
size1
=
i1
;
uint8_t
*
chunk2
=
data
+
size1
;
uint8_t
*
chunk2
=
data
+
size1
;
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-41.c
View file @
a4f8e94b
...
@@ -95,7 +95,8 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
...
@@ -95,7 +95,8 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
int
i
;
int
i
;
buf_size
=
cmp_buf_size
+
100
;
buf_size
=
cmp_buf_size
+
100
;
buf
=
alloca
(
buf_size
);
uint8_t
scratch
[
buf_size
];
buf
=
scratch
;
buf_pos
=
0
;
buf_pos
=
0
;
/*
/*
...
@@ -118,16 +119,17 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
...
@@ -118,16 +119,17 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
}
}
assert
(
buf
[
i
]
==
cmp_buf
[
i
]);
assert
(
buf
[
i
]
==
cmp_buf
[
i
]);
}
}
buf
=
0
;
}
}
static
void
static
void
partial_read
(
uint8_t
*
buf_0
,
size_t
size
)
{
partial_read
(
uint8_t
*
buf_0
,
size_t
size
)
{
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
uint8_t
buf_1
[
size
];
uint8_t
*
buf_1
=
alloca
(
size
);
uint8_t
buf_2
[
size
];
uint8_t
*
buf_2
=
alloca
(
size
);
uint8_t
buf_3
[
size
];
uint8_t
*
buf_3
=
alloca
(
size
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
...
@@ -137,8 +139,8 @@ partial_read(uint8_t *buf_0, size_t size) {
...
@@ -137,8 +139,8 @@ partial_read(uint8_t *buf_0, size_t size) {
* ^ buf_0 ^ buf_0+size
* ^ buf_0 ^ buf_0+size
* Try to read block by block.
* Try to read block by block.
*/
*/
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
size_t
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
for
(
size_t
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
buf_0
;
uint8_t
*
chunk1
=
buf_0
;
size_t
size1
=
i1
;
size_t
size1
=
i1
;
uint8_t
*
chunk2
=
buf_0
+
size1
;
uint8_t
*
chunk2
=
buf_0
+
size1
;
...
...
This diff is collapsed.
Click to expand it.
tests/tests-c-compiler/check-src/check-42.c
View file @
a4f8e94b
...
@@ -113,7 +113,8 @@ check_serialize() {
...
@@ -113,7 +113,8 @@ check_serialize() {
asn_fprint
(
stderr
,
&
asn_DEF_LogLine
,
&
ll
);
asn_fprint
(
stderr
,
&
asn_DEF_LogLine
,
&
ll
);
buf_size
=
128
;
buf_size
=
128
;
buf
=
alloca
(
buf_size
);
uint8_t
scratch
[
buf_size
];
buf
=
scratch
;
erval
=
der_encode
(
&
asn_DEF_LogLine
,
&
ll
,
buf_fill
,
0
);
erval
=
der_encode
(
&
asn_DEF_LogLine
,
&
ll
,
buf_fill
,
0
);
assert
(
erval
.
encoded
>
1
);
assert
(
erval
.
encoded
>
1
);
fprintf
(
stderr
,
"Encoded in %zd bytes
\n
"
,
erval
.
encoded
);
fprintf
(
stderr
,
"Encoded in %zd bytes
\n
"
,
erval
.
encoded
);
...
...
This diff is collapsed.
Click to expand it.
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