Re: New function normal_rand_array function to contrib/tablefunc. - Mailing list pgsql-hackers

From Andy Fan
Subject Re: New function normal_rand_array function to contrib/tablefunc.
Date
Msg-id 87zfmru1oi.fsf@163.com
Whole thread Raw
In response to New function normal_rand_array function to contrib/tablefunc.  (Andy Fan <zhihuifan1213@163.com>)
Responses Re: New function normal_rand_array function to contrib/tablefunc.
List pgsql-hackers
> 10). In this error:
>
> +        elog(ERROR, "unsupported type %d for rand_array function.",
> +             datatype);
>
> "datatype" is of type Oid, which is unsigned, and so it should use
> "%u" not "%d". Also, as above, it should not end with a period, so it
> should be:
>
> +        elog(ERROR, "unsupported type %u for rand_array function",
> +             datatype);

I remember my IDE could detect such issue before, but failed this
time. I just checked more today and it is still failing. Looks the
checker is not stable and I can't find out the reason so far.

main.c

#include <stdio.h>

int main(int argc, char *argv[])
{
    unsigned int i = 0;
    int x = 2;
    printf("i = %d\n", i);
    printf("i = %u\n", x);    
    return 0;
}

All the following commands succeed without any warnings.

clang -O0 -g main.c -o main -Wall -Wformat
gcc -g main.c -o main -Wall -Wformat

scan-build clang -g main.c -o main -Wall -Wformat
cppcheck main.c

clang: 18.1.6
gcc: 13.3.0

Only "cppcheck --enable=all main.c" catch the warnning.

Any hints on this will be appreicated.

-- 
Best Regards
Andy Fan




pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Collation & ctype method table, and extension hooks
Next
From: Dilip Kumar
Date:
Subject: Re: Can rs_cindex be < 0 for bitmap heap scans?