clang static analyzer warning fixes
[cparser] / wrappergen / write_fluffy.c
index f1a4021..7b66c74 100644 (file)
@@ -173,8 +173,6 @@ static void write_type(const type_t *type)
        case TYPE_FUNCTION:
                write_function_type(&type->function);
                return;
-       case TYPE_INVALID:
-               panic("invalid type found");
        case TYPE_COMPLEX:
        case TYPE_IMAGINARY:
        default:
@@ -227,7 +225,7 @@ static void write_expression(const expression_t *expression)
        case EXPR_LITERAL_INTEGER:
                fprintf(out, "%s", expression->literal.value.begin);
                break;
-       EXPR_UNARY_CASES
+       case EXPR_UNARY_CASES:
                write_unary_expression((const unary_expression_t*) expression);
                break;
        default:
@@ -262,7 +260,7 @@ static void write_variable(const entity_t *entity)
 
 static void write_function(const entity_t *entity)
 {
-       if (entity->function.statement != NULL) {
+       if (entity->function.body != NULL) {
                fprintf(stderr, "Warning: can't convert function bodies (at %s)\n",
                        entity->base.symbol->string);
        }
@@ -291,15 +289,13 @@ static void write_function(const entity_t *entity)
        if(function_type->variadic) {
                if(!first) {
                        fprintf(out, ", ");
-               } else {
-                       first = 0;
                }
                fputs("...", out);
        }
        fprintf(out, ")");
 
        const type_t *return_type = skip_typeref(function_type->return_type);
-       if(!is_type_atomic(return_type, ATOMIC_TYPE_VOID)) {
+       if (!is_type_void(return_type)) {
                fprintf(out, " : ");
                write_type(return_type);
        }
@@ -321,8 +317,7 @@ void write_fluffy_decls(FILE *output, const translation_unit_t *unit)
                        continue;
 
                type_t *type = entity->typedefe.type;
-               if(type->kind == TYPE_COMPOUND_STRUCT
-                               || type->kind == TYPE_COMPOUND_UNION) {
+               if (is_type_compound(type)) {
                        write_compound(entity->base.symbol, &type->compound);
                } else if(type->kind == TYPE_ENUM) {
                        write_enum(entity->base.symbol, &type->enumt);