Skip to content

Commit db0abbb

Browse files
committed
Mark needless return(bla) with a macro so we can shut up FlexeLint
1 parent 449dc16 commit db0abbb

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

ntimed_tricks.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@
8585
*/
8686
#define __match_proto__(xxx) /*lint -e{818} */
8787

88+
/*
89+
* Some functions never return, and there's nothing Turing can do about it.
90+
* Some compilers think you should still include a final return(bla) in
91+
* such functions, while other tools complain about unreachable code.
92+
* Wrapping in a macro means we can shut the tools up.
93+
*/
94+
95+
#define NEEDLESS_RETURN(foo) return(foo)
96+
8897
/**********************************************************************
8998
* Compiler tricks
9099
*/

ocx_stdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ getdst(enum ocx_chan chan)
7979
if (chan == OCX_DEBUG)
8080
return (stdout);
8181
WRONG("Wrong ocx_chan");
82-
return (NULL);
82+
NEEDLESS_RETURN(NULL);
8383
}
8484

8585
static void __match_proto__()

time_stuff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ tb_Now(struct timestamp *storage)
167167

168168
(void)storage;
169169
WRONG("No TB_Now");
170-
return (NULL);
170+
NEEDLESS_RETURN(NULL);
171171
}
172172

173173
tb_now_f *TB_Now = tb_Now;
@@ -179,7 +179,7 @@ tb_Sleep(double dur)
179179
{
180180
(void)dur;
181181
WRONG("No TB_Sleep");
182-
return (-1);
182+
NEEDLESS_RETURN(-1);
183183
}
184184

185185
tb_sleep_f *TB_Sleep = tb_Sleep;

udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,5 @@ Udp_Send(struct ocx *ocx, const struct udp_socket *usc,
199199
return (sendto(usc->fd6, buf, len, 0, ss, sl));
200200

201201
WRONG("Wrong AF_");
202-
return (0);
202+
NEEDLESS_RETURN(0);
203203
}

0 commit comments

Comments
 (0)