Changeset: 96e0b589fd1f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/96e0b589fd1f
Modified Files:
        clients/examples/C/bincopydata.c
Branch: Dec2025
Log Message:

Use unsigned types for bit manipulations and controlled overflow.


diffs (29 lines):

diff --git a/clients/examples/C/bincopydata.c b/clients/examples/C/bincopydata.c
--- a/clients/examples/C/bincopydata.c
+++ b/clients/examples/C/bincopydata.c
@@ -281,7 +281,7 @@ gen_inet4(FILE *f, bool byteswap, long n
 {
        (void)arg;
        (void)byteswap;
-       for (int v = 0; v < nrecs; v++) {
+       for (uint64_t v = 0; v < (uint64_t) nrecs; v++) {
                uint64_t i = (v == 3) ? 0x00000000 : (v + 1) * 1001001001;
                // always big endian
                fputc((i >> 24) % 256, f);
@@ -296,11 +296,11 @@ gen_inet6(FILE *f, bool byteswap, long n
 {
        (void)arg;
        (void)byteswap;
-       for (int v = 0; v < nrecs; v++) {
-               long i0 = (v + 1) * 2142970729L;
-               long i1 = (v + 1) * 2011938419L;
-               long i2 = (v + 1) * 1616437157L;
-               long i3 = (v + 1) * 1271098355L;
+       for (uint64_t v = 0; v < (uint64_t) nrecs; v++) {
+               uint64_t i0 = (v + 1) * 2142970729L;
+               uint64_t i1 = (v + 1) * 2011938419L;
+               uint64_t i2 = (v + 1) * 1616437157L;
+               uint64_t i3 = (v + 1) * 1271098355L;
                uint8_t rec[16] = {
                        (uint8_t)(i0 >> 24),
                        (uint8_t)(i0 >> 16),
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to