return len;
 }
 
-#define ZEROPAD        1               /* pad with zero */
-#define SIGN   2               /* unsigned/signed long */
+#define SIGN   1               /* unsigned/signed, must be 1 */
+#define ZEROPAD        2               /* pad with zero */
 #define PLUS   4               /* show plus */
 #define SPACE  8               /* space if plus */
 #define LEFT   16              /* left justified */
                spec.precision = i;
        /* leading space padding */
        spec.field_width -= spec.precision;
-       if (!(spec.flags & (ZEROPAD+LEFT))) {
+       if (!(spec.flags & (ZEROPAD | LEFT))) {
                while (--spec.field_width >= 0) {
                        if (buf < end)
                                *buf = ' ';
        if (spec->qualifier == 'L')
                spec->type = FORMAT_TYPE_LONG_LONG;
        else if (spec->qualifier == 'l') {
-               if (spec->flags & SIGN)
-                       spec->type = FORMAT_TYPE_LONG;
-               else
-                       spec->type = FORMAT_TYPE_ULONG;
+               BUILD_BUG_ON(FORMAT_TYPE_ULONG + SIGN != FORMAT_TYPE_LONG);
+               spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN);
        } else if (_tolower(spec->qualifier) == 'z') {
                spec->type = FORMAT_TYPE_SIZE_T;
        } else if (spec->qualifier == 't') {
                spec->type = FORMAT_TYPE_PTRDIFF;
        } else if (spec->qualifier == 'H') {
-               if (spec->flags & SIGN)
-                       spec->type = FORMAT_TYPE_BYTE;
-               else
-                       spec->type = FORMAT_TYPE_UBYTE;
+               BUILD_BUG_ON(FORMAT_TYPE_UBYTE + SIGN != FORMAT_TYPE_BYTE);
+               spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN);
        } else if (spec->qualifier == 'h') {
-               if (spec->flags & SIGN)
-                       spec->type = FORMAT_TYPE_SHORT;
-               else
-                       spec->type = FORMAT_TYPE_USHORT;
+               BUILD_BUG_ON(FORMAT_TYPE_USHORT + SIGN != FORMAT_TYPE_SHORT);
+               spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN);
        } else {
-               if (spec->flags & SIGN)
-                       spec->type = FORMAT_TYPE_INT;
-               else
-                       spec->type = FORMAT_TYPE_UINT;
+               BUILD_BUG_ON(FORMAT_TYPE_UINT + SIGN != FORMAT_TYPE_INT);
+               spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN);
        }
 
        return ++fmt - start;