]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib: helping compiler with early returns
authorMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 29 Jun 2015 23:08:44 +0000 (01:08 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 29 Jun 2015 23:08:44 +0000 (01:08 +0200)
lib/defines.h

index 017a14087e935188514c59408b04429dc92514ef..9709380c9d164c07828ad38fe3fb0f6b4b7ebef5 100644 (file)
  * Error codes.
  */
 #define kr_ok() 0
-#define kr_error(x) -abs(x)
+/* Mark as cold to mark all branches as unlikely. */
+static inline int __attribute__((__cold__)) kr_error(int x) {
+       return -abs(x);
+}
 #define kr_strerror(x) strerror(abs(x))
 
 /*