[Git][NTPsec/ntpsec][master] 7 commits: libisc: mark two functions attribute const

Gary E. Miller gitlab at mg.gitlab.com
Sat Apr 22 03:53:38 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
583f97ec by Gary E. Miller at 2017-04-21T20:18:24-07:00
libisc: mark two functions attribute const

- - - - -
72a37908 by Gary E. Miller at 2017-04-21T20:19:26-07:00
lib_srtbuf: note where an attribute const fails

- - - - -
f33a5987 by Gary E. Miller at 2017-04-21T20:30:28-07:00
waf: remove annoying warning: -Wsuggest-attribute=const

many false positives, and it hates Unity.

- - - - -
ab1b97ec by Gary E. Miller at 2017-04-21T20:41:10-07:00
ntp_filegen: mark one attribute pure.

- - - - -
ce17da40 by Gary E. Miller at 2017-04-21T20:46:18-07:00
ntp_leapsec: mark function attribute pure

- - - - -
3e3be90f by Gary E. Miller at 2017-04-21T20:46:34-07:00
refclock_trimble: mark one function static and attribute pure

- - - - -
fef5b116 by Gary E. Miller at 2017-04-21T20:51:23-07:00
libisc/assertions: fix possibly uninit variable.

No idea if just a false positive.

- - - - -


8 changed files:

- libisc/assertions.c
- libisc/include/isc/assertions.h
- libisc/include/isc/backtrace.h
- libntp/lib_strbuf.c
- ntpd/ntp_filegen.c
- ntpd/ntp_leapsec.c
- ntpd/refclock_trimble.c
- wafhelpers/configure.py


Changes:

=====================================
libisc/assertions.c
=====================================
--- a/libisc/assertions.c
+++ b/libisc/assertions.c
@@ -93,14 +93,14 @@ default_callback(const char *file, int line, isc_assertiontype_t type,
 		 const char *cond)
 {
 	void *tracebuf[BACKTRACE_MAXFRAME];
-	int i, nframes;
+	int i, nframes = 0;
 	const char *logsuffix = ".";
 	const char *fname;
 	isc_result_t result;
 
 	result = isc_backtrace_gettrace(tracebuf, BACKTRACE_MAXFRAME, &nframes);
-		if (result == ISC_R_SUCCESS && nframes > 0)
-			logsuffix = ", back trace";
+	if (result == ISC_R_SUCCESS && nframes > 0)
+		logsuffix = ", back trace";
 
 	fprintf(stderr, "%s:%d: %s(%s) failed%s\n",
 		file, line, isc_assertion_typetotext(type), cond, logsuffix);


=====================================
libisc/include/isc/assertions.h
=====================================
--- a/libisc/include/isc/assertions.h
+++ b/libisc/include/isc/assertions.h
@@ -35,7 +35,8 @@ void
 isc_assertion_setcallback(isc_assertioncallback_t);
 
 const char *
-isc_assertion_typetotext(isc_assertiontype_t type);
+isc_assertion_typetotext(isc_assertiontype_t type)
+			__attribute__((const));
 
 #if defined(ISC_CHECK_ALL) || defined(__COVERITY__)
 #define ISC_CHECK_REQUIRE		1


=====================================
libisc/include/isc/backtrace.h
=====================================
--- a/libisc/include/isc/backtrace.h
+++ b/libisc/include/isc/backtrace.h
@@ -49,7 +49,8 @@ extern const isc_backtrace_symmap_t isc__backtrace_symtable[];
 
 ISC_LANG_BEGINDECLS
 isc_result_t
-isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes);
+isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes)
+		       __attribute__((const));
 /*%<
  * Get a back trace of the running process above this function itself.  On
  * success, addrs[i] will store the address of the call point of the i-th


=====================================
libntp/lib_strbuf.c
=====================================
--- a/libntp/lib_strbuf.c
+++ b/libntp/lib_strbuf.c
@@ -23,6 +23,8 @@ int		lib_nextbuf;
  * refuse to consider a module a candidate to be linked unless it
  * has an executable entry point called from somewhere else that
  * is linked.
+ *
+ * marking this __attribute__((const)) kills thelinker too.
  */
 void
 init_lib(void)


=====================================
ntpd/ntp_filegen.c
=====================================
--- a/ntpd/ntp_filegen.c
+++ b/ntpd/ntp_filegen.c
@@ -40,7 +40,8 @@
 #define SUFFIX_SEP '.'
 
 static	void	filegen_open	(FILEGEN *, const time_t);
-static	int	valid_fileref	(const char *, const char *);
+static	int	valid_fileref	(const char *, const char *)
+			         __attribute__((pure));
 static	void	filegen_init	(const char *, const char *, FILEGEN *);
 #ifdef	DEBUG
 static	void	filegen_uninit		(FILEGEN *);


=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -76,7 +76,7 @@ static bool  _electric;
 /* Forward decls of local helpers */
 static bool   add_range(leap_table_t*, const leap_info_t*);
 static char * get_line(leapsec_reader, void*, char*, size_t);
-static char * skipws(char*);
+static char * skipws(char*) __attribute__((pure));
 static bool   parsefail(const char * cp, const char * ep);
 static void   reload_limits(leap_table_t*, time_t);
 static void   reset_times(leap_table_t*);


=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -212,7 +212,7 @@ struct refclock refclock_trimble = {
 	NULL			/* timer - not used */
 };
 
-int day_of_year (char *dt);
+static int day_of_year (char *dt) __attribute__((pure));
 
 /* Extract the clock type from the mode setting */
 #define CLK_TYPE(x) ((int)(((x)->ttl) & 0x7F))
@@ -516,7 +516,7 @@ trimble_shutdown (
 /* 
  * unpack_date - get day and year from date
  */
-int
+static int
 day_of_year (
 	char * dt
 	)


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -322,10 +322,10 @@ def cmd_configure(ctx, config):
             # fails on Solaris and OpenBSD 6
             # complains about a Bison bug
             ('w_sign_conversion', "-Wsign-conversion"),
-            # fails on clang
-            ('w_suggest_attribute_const', "-Wsuggest-attribute=const"),
-            # fails on clang
-            ('w_suggest_attribute_pure', "-Wsuggest-attribute=pure"),
+            # fails on clang, lot's of false positives and Unity complaints
+            # ('w_suggest_attribute_const', "-Wsuggest-attribute=const"),
+            # fails on clang, lot's of false positives and Unity complaints
+            #('w_suggest_attribute_pure', "-Wsuggest-attribute=pure"),
             ]
 
     ctx.env.CFLAGS = [



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/223dac94b3526d98d252d4a9249ed4b151c0dc1a...fef5b1169e83d00e13dcc59ca6d4534c19b045df

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/223dac94b3526d98d252d4a9249ed4b151c0dc1a...fef5b1169e83d00e13dcc59ca6d4534c19b045df
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170422/fdb02463/attachment.html>


More information about the vc mailing list