[master] 76390f6 Introduce the NEEDLESS macro to mark unreached statements

Nils Goroll nils.goroll at uplex.de
Thu Dec 8 14:51:05 CET 2016


commit 76390f6070ea2bbdb0713c3b353ee5ecceaf506d
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Aug 24 12:16:17 2016 +0200

    Introduce the NEEDLESS macro to mark unreached statements
    
    and define it as NOP for Sun CC

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 9d69daa..ceb442c 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -543,7 +543,7 @@ vca_acct(void *arg)
 		now = VTIM_real();
 		VSC_C_main->uptime = (uint64_t)(now - t0);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index 479d1fa..2fd8b19 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -384,8 +384,8 @@ vbp_thread(struct worker *wrk, void *priv)
 			binheap_insert(vbp_heap, vt);
 		}
 	}
-	Lck_Unlock(&vbp_mtx);
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(Lck_Unlock(&vbp_mtx));
+	NEEDLESS(return NULL);
 }
 
 
diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 3206492..f236b2c 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -368,5 +368,5 @@ ban_lurker(struct worker *wrk, void *priv)
 		Lck_Unlock(&ban_mtx);
 	}
 	pthread_exit(0);
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index f20c2a1..b93cc59 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -341,7 +341,7 @@ exp_thread(struct worker *wrk, void *priv)
 		else
 			tnext = exp_expire(ep, t);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 314945c..47e8611 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -226,7 +226,7 @@ pool_poolherder(void *priv)
 		Lck_Unlock(&pool_mtx);
 		VSC_C_main->thread_queue_len = u;
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index a927cb1..5656b31 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -478,7 +478,7 @@ vsm_cleaner(void *priv)
 		AZ(pthread_mutex_unlock(&vsm_mtx));
 		VTIM_sleep(1.1);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index 7bb19d7..54b6694 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -149,7 +149,7 @@ VRT_priv_top(VRT_CTX, void *vmod_id)
 		return (vrt_priv_dynamic(ctx, id, (uintptr_t)vmod_id));
 	} else
 		WRONG("PRIV_TOP is only accessible in client VCL context");
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 55d149c..1e63c3b 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -70,7 +70,7 @@ wrk_bgthread(void *arg)
 
 	WRONG("BgThread terminated");
 
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 void
@@ -539,5 +539,5 @@ pool_herder(void *priv)
 		}
 		Lck_Unlock(&pp->mtx);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c
index 3b09fc5..97fa154 100644
--- a/bin/varnishd/hash/hash_critbit.c
+++ b/bin/varnishd/hash/hash_critbit.c
@@ -327,7 +327,7 @@ hcb_cleaner(struct worker *wrk, void *priv)
 		Pool_Sumstat(wrk);
 		VTIM_sleep(cache_param->critbit_cooloff);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/hpack/vhp_decode.c b/bin/varnishd/hpack/vhp_decode.c
index 15e05fd..0e2d34c 100644
--- a/bin/varnishd/hpack/vhp_decode.c
+++ b/bin/varnishd/hpack/vhp_decode.c
@@ -733,7 +733,7 @@ decode(struct vhd_decode *d, struct vht_table *tbl, uint8_t *in, size_t in_l,
 		}
 	}
 
-	NEEDLESS_RETURN(0);
+	NEEDLESS(return (VHD_OK));
 }
 
 #define CHECK_RET(r, e)					\
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 730f2d6..8d96a5f 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -313,7 +313,7 @@ smp_thread(struct worker *wrk, void *priv)
 	Lck_Unlock(&sc->mtx);
 	pthread_exit(0);
 
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index ed3a39c..282d7a8 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -206,7 +206,7 @@ VSL(SLT_Debug, vwp->pollfd[i].fd, "POLL loop i=%d revents=0x%x", i, vwp->pollfd[
 		if (vwp->pollfd[0].revents)
 			vwp_dopipe(vwp);
 	}
-	NEEDLESS_RETURN(NULL);
+	NEEDLESS(return NULL);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 561c0a7..a5f6ee3 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -457,7 +457,7 @@ do_curses(void *arg)
 			pthread_mutex_unlock(&mtx);
 		}
 	}
-	pthread_exit(NULL);
+	NEEDLESS(pthread_exit(NULL));
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c
index e8b1928..377fd1a 100644
--- a/bin/varnishtest/vtc_server.c
+++ b/bin/varnishtest/vtc_server.c
@@ -255,7 +255,7 @@ server_dispatch_thread(void *priv)
 		s2->run = 1;
 		AZ(pthread_create(&s2->tp, NULL, server_dispatch_wrk, s2));
 	}
-	return(NULL);
+	NEEDLESS(return(NULL));
 }
 
 static void
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index eccb4ca..f6a005c 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -293,8 +293,7 @@ do_curses(void *arg)
 			break;
 		}
 	}
-	return NULL;
-
+	NEEDLESS(return NULL);
 }
 
 static void
diff --git a/include/vdef.h b/include/vdef.h
index 3ec0608..3565d05 100644
--- a/include/vdef.h
+++ b/include/vdef.h
@@ -111,6 +111,12 @@
  */
 #define __state_variable__(varname)	varname /*lint -esym(838,varname) */
 
+#ifdef __SUNPRO_C
+#define NEEDLESS_RETURN		{}
+#define NEEDLESS(s)		{}
+#else
 #define NEEDLESS_RETURN		return
+#define NEEDLESS(s)		s
+#endif
 
 #endif /* VDEF_H_INCLUDED */
diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index 02c9cf3..48042cb 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -298,7 +298,7 @@ vslq_exec(const struct vex *vex, struct VSL_transaction * const ptrans[])
 	default:
 		return (vslq_test(vex, ptrans));
 	}
-	NEEDLESS_RETURN(0);
+	NEEDLESS(return 0);
 }
 
 struct vslq_query *



More information about the varnish-commit mailing list