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
cdf62dce
Commit
cdf62dce
authored
Apr 08, 2014
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
io: io_never for events that should never happen.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
2a8b4826
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
35 additions
and
10 deletions
+35
-10
ccan/io/io.c
ccan/io/io.c
+10
-0
ccan/io/io.h
ccan/io/io.h
+15
-0
ccan/io/test/run-01-start-finish.c
ccan/io/test/run-01-start-finish.c
+1
-1
ccan/io/test/run-02-read.c
ccan/io/test/run-02-read.c
+1
-1
ccan/io/test/run-03-readpartial.c
ccan/io/test/run-03-readpartial.c
+1
-1
ccan/io/test/run-04-writepartial.c
ccan/io/test/run-04-writepartial.c
+1
-1
ccan/io/test/run-05-write.c
ccan/io/test/run-05-write.c
+1
-1
ccan/io/test/run-06-idle.c
ccan/io/test/run-06-idle.c
+1
-1
ccan/io/test/run-15-timeout.c
ccan/io/test/run-15-timeout.c
+1
-1
ccan/io/test/run-17-homemade-io.c
ccan/io/test/run-17-homemade-io.c
+1
-1
ccan/io/test/run-19-always.c
ccan/io/test/run-19-always.c
+1
-1
ccan/io/test/run-set_alloc.c
ccan/io/test/run-set_alloc.c
+1
-1
No files found.
ccan/io/io.c
View file @
cdf62dce
...
...
@@ -531,6 +531,16 @@ struct io_plan io_break_(void *ret, struct io_plan plan)
return
plan
;
}
static
struct
io_plan
io_never_called
(
struct
io_conn
*
conn
,
void
*
arg
)
{
abort
();
}
struct
io_plan
io_never
(
void
)
{
return
io_always_
(
io_never_called
,
NULL
);
}
int
io_conn_fd
(
const
struct
io_conn
*
conn
)
{
return
conn
->
fd
.
fd
;
...
...
ccan/io/io.h
View file @
cdf62dce
...
...
@@ -490,6 +490,21 @@ bool io_is_idle(const struct io_conn *conn);
#define io_break(ret, plan) (io_plan_no_debug(), io_break_((ret), (plan)))
struct
io_plan
io_break_
(
void
*
ret
,
struct
io_plan
plan
);
/**
* io_never - assert if callback is called.
*
* Sometimes you want to make it clear that a callback should never happen
* (eg. for io_break). This will assert() if called.
*
* Example:
* static struct io_plan break_out(struct io_conn *conn, void *unused)
* {
* // We won't ever return from io_break
* return io_break(conn, io_never());
* }
*/
struct
io_plan
io_never
(
void
);
/* FIXME: io_recvfrom/io_sendto */
/**
...
...
ccan/io/test/run-01-start-finish.c
View file @
cdf62dce
...
...
@@ -16,7 +16,7 @@ static void finish_ok(struct io_conn *conn, int *state)
ok1
(
*
state
==
1
);
ok1
(
io_conn_fd
(
conn
)
==
expected_fd
);
(
*
state
)
++
;
io_break
(
state
+
1
,
io_
idle
());
io_break
(
state
+
1
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
int
*
state
)
...
...
ccan/io/test/run-02-read.c
View file @
cdf62dce
...
...
@@ -19,7 +19,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
1
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
ccan/io/test/run-03-readpartial.c
View file @
cdf62dce
...
...
@@ -20,7 +20,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
1
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
ccan/io/test/run-04-writepartial.c
View file @
cdf62dce
...
...
@@ -20,7 +20,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
1
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
ccan/io/test/run-05-write.c
View file @
cdf62dce
...
...
@@ -20,7 +20,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
1
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
ccan/io/test/run-06-idle.c
View file @
cdf62dce
...
...
@@ -39,7 +39,7 @@ static void finish_idle(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
3
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
struct
io_plan
never
(
struct
io_conn
*
conn
,
void
*
arg
)
...
...
ccan/io/test/run-15-timeout.c
View file @
cdf62dce
...
...
@@ -38,7 +38,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
2
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
ccan/io/test/run-17-homemade-io.c
View file @
cdf62dce
...
...
@@ -20,7 +20,7 @@ static void finish_ok(struct io_conn *conn, struct packet *pkt)
{
ok1
(
pkt
->
state
==
3
);
pkt
->
state
++
;
io_break
(
pkt
,
io_
idle
());
io_break
(
pkt
,
io_
never
());
}
static
int
do_read_packet
(
int
fd
,
struct
io_plan
*
plan
)
...
...
ccan/io/test/run-19-always.c
View file @
cdf62dce
...
...
@@ -20,7 +20,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
1
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
struct
io_plan
write_buf
(
struct
io_conn
*
conn
,
struct
data
*
d
)
...
...
ccan/io/test/run-set_alloc.c
View file @
cdf62dce
...
...
@@ -95,7 +95,7 @@ static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1
(
d
->
state
==
2
);
d
->
state
++
;
io_break
(
d
,
io_
idle
());
io_break
(
d
,
io_
never
());
}
static
void
init_conn
(
int
fd
,
struct
data
*
d
)
...
...
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