Dear Daniel, Jelte

Thank you for creating a good feature!
While checking the buildfarm, I found a failure on NetBSD caused by the added 
code[1]:

```
fe-connect.c: In function 'libpq_prng_init':
fe-connect.c:1048:11: error: cast from pointer to integer of different size 
[-Werror=pointer-to-int-cast]
 1048 |  rseed = ((uint64) conn) ^
      |           ^
cc1: all warnings being treated as errors
```

This failure seemed to occurr when the pointer is casted to different size.
And while checking more, I found that this machine seemed that size of pointer 
is 4 byte [2],
whereas sizeof(uint64) is 8.

```
checking size of void *... (cached) 4
```

I could not test because I do not have NetBSD, but I have come up with
Following solution to avoid the failure. sizeof(uintptr_t) will be addressed
based on the environment. How do you think?

```
diff --git a/src/interfaces/libpq/fe-connect.c 
b/src/interfaces/libpq/fe-connect.c
index a13ec16b32..bb7347cb0c 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1045,7 +1045,7 @@ libpq_prng_init(PGconn *conn)
 
        gettimeofday(&tval, NULL);
 
-       rseed = ((uint64) conn) ^
+       rseed = ((uintptr_t) conn) ^
                        ((uint64) getpid()) ^
                        ((uint64) tval.tv_usec) ^
                        ((uint64) tval.tv_sec);
```

[1]: 
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mamba&dt=2023-03-29%2023%3A24%3A44
[2]: 
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=mamba&dt=2023-03-29%2023%3A24%3A44&stg=configure

Best Regards,
Hayato Kuroda
FUJITSU LIMITED



Reply via email to