[115464] trunk/base/src/machista1.0/libmachista.c

jeremyhu at macports.org jeremyhu at macports.org
Thu Jan 2 14:08:00 PST 2014


Revision: 115464
          https://trac.macports.org/changeset/115464
Author:   jeremyhu at macports.org
Date:     2014-01-02 14:07:59 -0800 (Thu, 02 Jan 2014)
Log Message:
-----------
Use fls rather than reinventing it

Modified Paths:
--------------
    trunk/base/src/machista1.0/libmachista.c

Modified: trunk/base/src/machista1.0/libmachista.c
===================================================================
--- trunk/base/src/machista1.0/libmachista.c	2014-01-02 19:21:11 UTC (rev 115463)
+++ trunk/base/src/machista1.0/libmachista.c	2014-01-02 22:07:59 UTC (rev 115464)
@@ -41,6 +41,7 @@
 
 #include <err.h>
 #include <string.h>
+#include <strings.h>
 
 #ifdef __MACH__
 #include <mach-o/fat.h>
@@ -530,11 +531,8 @@
 
 /* Returns string representation of the MACHO_* error code constants */
 const char *macho_strerror(int err) {
-    int num = 0;
-    while (err > 0) {
-        err >>= 1;
-        num++;
-    }
+    int num = fls(err);
+
     static char *errors[] = {
         /* 0x00 */ "Success",
         /* 0x01 */ "Error opening or reading file",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140102/e38e0771/attachment.html>


More information about the macports-changes mailing list