Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
148c0948
Commit
148c0948
authored
Mar 21, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typesafe: fix warnings with gcc's -Wcast-qual
Don't implicitly cast away const in the tests.
parent
3d27344a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
28 deletions
+38
-28
ccan/typesafe_cb/test/compile_fail-typesafe_cb.c
ccan/typesafe_cb/test/compile_fail-typesafe_cb.c
+2
-1
ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c
ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c
+1
-1
ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c
ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c
+5
-4
ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c
ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c
+4
-3
ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c
ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c
+4
-3
ccan/typesafe_cb/test/run.c
ccan/typesafe_cb/test/run.c
+22
-16
No files found.
ccan/typesafe_cb/test/compile_fail-typesafe_cb.c
View file @
148c0948
...
...
@@ -14,6 +14,7 @@ static void my_callback(char *p)
int
main
(
int
argc
,
char
*
argv
[])
{
char
str
[]
=
"hello world"
;
#ifdef FAIL
int
*
p
;
#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
...
...
@@ -25,7 +26,7 @@ int main(int argc, char *argv[])
p
=
NULL
;
/* This should work always. */
register_callback
(
my_callback
,
"hello world"
);
register_callback
(
my_callback
,
str
);
/* This will fail with FAIL defined */
register_callback
(
my_callback
,
p
);
...
...
ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c
View file @
148c0948
...
...
@@ -3,7 +3,7 @@
/* NULL args for callback function should be OK for _exact and _def. */
static
void
_register_callback
(
void
(
*
cb
)(
void
*
arg
),
void
*
arg
)
static
void
_register_callback
(
void
(
*
cb
)(
const
void
*
arg
),
const
void
*
arg
)
{
}
...
...
ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c
View file @
148c0948
...
...
@@ -41,9 +41,10 @@ static void my_callback_post(/*const*/ char *p, int x)
int
main
(
int
argc
,
char
*
argv
[])
{
register_callback
(
my_callback
,
"hello world"
);
register_callback_def
(
my_callback
,
"hello world"
);
register_callback_pre
(
my_callback_pre
,
"hello world"
);
register_callback_post
(
my_callback_post
,
"hello world"
);
char
p
[]
=
"hello world"
;
register_callback
(
my_callback
,
p
);
register_callback_def
(
my_callback
,
p
);
register_callback_pre
(
my_callback_pre
,
p
);
register_callback_post
(
my_callback_post
,
p
);
return
0
;
}
ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c
View file @
148c0948
...
...
@@ -39,8 +39,9 @@ static void my_callback_post(/* volatile */ char *p, int x)
int
main
(
int
argc
,
char
*
argv
[])
{
register_callback
(
my_callback
,
"hello world"
);
register_callback_pre
(
my_callback_pre
,
"hello world"
);
register_callback_post
(
my_callback_post
,
"hello world"
);
char
p
[]
=
"hello world"
;
register_callback
(
my_callback
,
p
);
register_callback_pre
(
my_callback_pre
,
p
);
register_callback_post
(
my_callback_post
,
p
);
return
0
;
}
ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c
View file @
148c0948
...
...
@@ -38,8 +38,9 @@ static void my_callback_post(/*const*/ char *p, int x)
int
main
(
int
argc
,
char
*
argv
[])
{
register_callback
(
my_callback
,
"hello world"
);
register_callback_pre
(
my_callback_pre
,
"hello world"
);
register_callback_post
(
my_callback_post
,
"hello world"
);
char
p
[]
=
"hello world"
;
register_callback
(
my_callback
,
p
);
register_callback_pre
(
my_callback_pre
,
p
);
register_callback_post
(
my_callback_post
,
p
);
return
0
;
}
ccan/typesafe_cb/test/run.c
View file @
148c0948
#include <ccan/typesafe_cb/typesafe_cb.h>
#include <string.h>
#include <stdint.h>
#include <ccan/tap/tap.h>
static
char
dummy
=
0
;
...
...
@@ -49,7 +50,8 @@ static void my_callback_onearg_const(const char *p)
static
void
my_callback_onearg_volatile
(
volatile
char
*
p
)
{
ok1
(
strcmp
((
char
*
)
p
,
"hello world"
)
==
0
);
/* Double cast avoids warning on gcc's -Wcast-qual */
ok1
(
strcmp
((
char
*
)(
intptr_t
)
p
,
"hello world"
)
==
0
);
}
static
void
my_callback_preargs
(
int
a
,
int
b
,
char
*
p
)
...
...
@@ -103,53 +105,57 @@ static void my_callback_postargs_volatile(volatile char *p, int a, int b)
struct
callback_onearg
{
void
(
*
fn
)(
void
*
arg
);
void
*
arg
;
const
void
*
arg
;
};
struct
callback_onearg
cb_onearg
=
{
typesafe_cb
(
void
,
my_callback_onearg
,
"hello world"
),
"hello world"
};
=
{
typesafe_cb
(
void
,
my_callback_onearg
,
(
char
*
)(
intptr_t
)
"hello world"
),
"hello world"
};
struct
callback_preargs
{
void
(
*
fn
)(
int
a
,
int
b
,
void
*
arg
);
void
*
arg
;
const
void
*
arg
;
};
struct
callback_preargs
cb_preargs
=
{
typesafe_cb_preargs
(
void
,
my_callback_preargs
,
"hi"
,
int
,
int
),
"hi"
};
=
{
typesafe_cb_preargs
(
void
,
my_callback_preargs
,
(
char
*
)(
intptr_t
)
"hi"
,
int
,
int
),
"hi"
};
struct
callback_postargs
{
void
(
*
fn
)(
void
*
arg
,
int
a
,
int
b
);
void
*
arg
;
const
void
*
arg
;
};
struct
callback_postargs
cb_postargs
=
{
typesafe_cb_postargs
(
void
,
my_callback_postargs
,
"hi"
,
int
,
int
),
"hi"
};
=
{
typesafe_cb_postargs
(
void
,
my_callback_postargs
,
(
char
*
)(
intptr_t
)
"hi"
,
int
,
int
),
"hi"
};
int
main
(
int
argc
,
char
*
argv
[])
{
void
*
p
=
&
dummy
;
unsigned
long
l
=
(
unsigned
long
)
p
;
char
str
[]
=
"hello world"
;
plan_tests
(
2
+
3
+
3
+
3
);
set_some_value
(
p
);
set_some_value
(
l
);
callback_onearg
(
my_callback_onearg
,
"hello world"
);
callback_onearg
(
my_callback_onearg_const
,
"hello world"
);
callback_onearg
(
my_callback_onearg_volatile
,
"hello world"
);
callback_onearg
(
my_callback_onearg
,
str
);
callback_onearg
(
my_callback_onearg_const
,
str
);
callback_onearg
(
my_callback_onearg_volatile
,
str
);
callback_preargs
(
my_callback_preargs
,
"hello world"
);
callback_preargs
(
my_callback_preargs
,
str
);
#if 0 /* FIXME */
callback_preargs(my_callback_preargs_const,
"hello world"
);
callback_preargs(my_callback_preargs_volatile,
"hello world"
);
callback_preargs(my_callback_preargs_const,
str
);
callback_preargs(my_callback_preargs_volatile,
str
);
#endif
callback_postargs
(
my_callback_postargs
,
"hello world"
);
callback_postargs
(
my_callback_postargs
,
str
);
#if 0 /* FIXME */
callback_postargs(my_callback_postargs_const,
"hello world"
);
callback_postargs(my_callback_postargs_volatile,
"hello world"
);
callback_postargs(my_callback_postargs_const,
str
);
callback_postargs(my_callback_postargs_volatile,
str
);
#endif
return
exit_status
();
...
...
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