1616// under the License.
1717
1818#include <errno.h>
19+ #include <inttypes.h>
1920#include <stdio.h>
2021#include <string.h>
2122
@@ -300,8 +301,8 @@ static int ArrowIpcDecoderSetMetadata(struct ArrowSchema* schema,
300301
301302 if (n_pairs > 2147483647 ) {
302303 ArrowErrorSet (error ,
303- "Expected between 0 and 2147483647 key/value pairs but found %ld" ,
304- ( long ) n_pairs );
304+ "Expected between 0 and 2147483647 key/value pairs but found %" PRId64 ,
305+ n_pairs );
305306 return EINVAL ;
306307 }
307308
@@ -381,7 +382,7 @@ static int ArrowIpcDecoderSetTypeInt(struct ArrowSchema* schema,
381382 default :
382383 ArrowErrorSet (error ,
383384 "Expected signed int bitwidth of 8, 16, 32, or 64 but got %d" ,
384- ( int ) bitwidth );
385+ bitwidth );
385386 return EINVAL ;
386387 }
387388 } else {
@@ -401,7 +402,7 @@ static int ArrowIpcDecoderSetTypeInt(struct ArrowSchema* schema,
401402 default :
402403 ArrowErrorSet (error ,
403404 "Expected unsigned int bitwidth of 8, 16, 32, or 64 but got %d" ,
404- ( int ) bitwidth );
405+ bitwidth );
405406 return EINVAL ;
406407 }
407408 }
@@ -422,8 +423,7 @@ static int ArrowIpcDecoderSetTypeFloatingPoint(struct ArrowSchema* schema,
422423 case ns (Precision_DOUBLE ):
423424 return ArrowIpcDecoderSetTypeSimple (schema , NANOARROW_TYPE_DOUBLE , error );
424425 default :
425- ArrowErrorSet (error , "Unexpected FloatingPoint Precision value: %d" ,
426- (int )precision );
426+ ArrowErrorSet (error , "Unexpected FloatingPoint Precision value: %d" , precision );
427427 return EINVAL ;
428428 }
429429}
@@ -447,7 +447,7 @@ static int ArrowIpcDecoderSetTypeDecimal(struct ArrowSchema* schema,
447447 ArrowSchemaSetTypeDecimal (schema , NANOARROW_TYPE_DECIMAL256 , precision , scale );
448448 break ;
449449 default :
450- ArrowErrorSet (error , "Unexpected Decimal bitwidth value: %d" , ( int ) bitwidth );
450+ ArrowErrorSet (error , "Unexpected Decimal bitwidth value: %d" , bitwidth );
451451 return EINVAL ;
452452 }
453453
@@ -518,7 +518,7 @@ static int ArrowIpcDecoderSetTypeTime(struct ArrowSchema* schema,
518518 break ;
519519
520520 default :
521- ArrowErrorSet (error , "Unexpected Time TimeUnit value: %d" , ( int ) time_unit );
521+ ArrowErrorSet (error , "Unexpected Time TimeUnit value: %d" , time_unit );
522522 return EINVAL ;
523523 }
524524
@@ -584,7 +584,7 @@ static int ArrowIpcDecoderSetTypeInterval(struct ArrowSchema* schema,
584584 return ArrowIpcDecoderSetTypeSimple (schema , NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO ,
585585 error );
586586 default :
587- ArrowErrorSet (error , "Unexpected Interval unit value: %d" , ( int ) interval_unit );
587+ ArrowErrorSet (error , "Unexpected Interval unit value: %d" , interval_unit );
588588 return EINVAL ;
589589 }
590590}
@@ -645,8 +645,8 @@ static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema,
645645
646646 if (n_children < 0 || n_children > 127 ) {
647647 ArrowErrorSet (error ,
648- "Expected between 0 and 127 children for Union type but found %ld" ,
649- ( long ) n_children );
648+ "Expected between 0 and 127 children for Union type but found %" PRId64 ,
649+ n_children );
650650 return EINVAL ;
651651 }
652652
@@ -672,7 +672,7 @@ static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema,
672672 format_out_size -= n_chars ;
673673 break ;
674674 default :
675- ArrowErrorSet (error , "Unexpected Union UnionMode value: %d" , ( int ) union_mode );
675+ ArrowErrorSet (error , "Unexpected Union UnionMode value: %d" , union_mode );
676676 return EINVAL ;
677677 }
678678
@@ -686,10 +686,10 @@ static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema,
686686 int64_t n_type_ids = flatbuffers_int32_vec_len (type_ids );
687687
688688 if (n_type_ids != n_children ) {
689- ArrowErrorSet (
690- error ,
691- "Expected between %ld children for Union type with %ld typeIds but found %ld" ,
692- ( long ) n_type_ids , ( long ) n_type_ids , ( long ) n_children );
689+ ArrowErrorSet (error ,
690+ "Expected between %" PRId64 " children for Union type with %" PRId64
691+ " typeIds but found %" PRId64 ,
692+ n_type_ids , n_type_ids , n_children );
693693 return EINVAL ;
694694 }
695695
@@ -705,8 +705,8 @@ static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema,
705705 }
706706
707707 for (int64_t i = 1 ; i < n_type_ids ; i ++ ) {
708- n_chars = snprintf (format_cursor , format_out_size , ",%d" ,
709- ( int ) flatbuffers_int32_vec_at (type_ids , i ));
708+ n_chars = snprintf (format_cursor , format_out_size , ",%" PRId32 ,
709+ flatbuffers_int32_vec_at (type_ids , i ));
710710 format_cursor += n_chars ;
711711 format_out_size -= n_chars ;
712712
@@ -727,7 +727,7 @@ static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema,
727727 }
728728
729729 for (int64_t i = 1 ; i < n_children ; i ++ ) {
730- n_chars = snprintf (format_cursor , format_out_size , ",%d" , ( int ) i );
730+ n_chars = snprintf (format_cursor , format_out_size , ",%" PRId64 , i );
731731 format_cursor += n_chars ;
732732 format_out_size -= n_chars ;
733733
@@ -792,7 +792,7 @@ static int ArrowIpcDecoderSetType(struct ArrowSchema* schema, ns(Field_table_t)
792792 return ArrowIpcDecoderSetTypeUnion (schema , ns (Field_type_get (field )), n_children ,
793793 error );
794794 default :
795- ArrowErrorSet (error , "Unrecognized Field type with value %d" , ( int ) type_type );
795+ ArrowErrorSet (error , "Unrecognized Field type with value %d" , type_type );
796796 return EINVAL ;
797797 }
798798}
@@ -878,7 +878,7 @@ static int ArrowIpcDecoderDecodeSchemaHeader(struct ArrowIpcDecoder* decoder,
878878 default :
879879 ArrowErrorSet (error ,
880880 "Expected Schema endianness of 0 (little) or 1 (big) but got %d" ,
881- ( int ) endianness );
881+ endianness );
882882 return EINVAL ;
883883 }
884884
@@ -920,14 +920,14 @@ static int ArrowIpcDecoderDecodeRecordBatchHeader(struct ArrowIpcDecoder* decode
920920 // Check field node and buffer count. We have one more field and buffer
921921 // because we count the root struct and the flatbuffer message does not.
922922 if ((n_fields + 1 ) != private_data -> n_fields ) {
923- ArrowErrorSet (error , "Expected %ld field nodes in message but found %ld" ,
924- ( long ) private_data -> n_fields - 1 , ( long ) n_fields );
923+ ArrowErrorSet (error , "Expected %" PRId64 " field nodes in message but found %" PRId64 ,
924+ private_data -> n_fields - 1 , n_fields );
925925 return EINVAL ;
926926 }
927927
928928 if ((n_buffers + 1 ) != private_data -> n_buffers ) {
929- ArrowErrorSet (error , "Expected %ld buffers in message but found %ld" ,
930- ( long ) private_data -> n_buffers - 1 , ( long ) n_buffers );
929+ ArrowErrorSet (error , "Expected %" PRId64 " buffers in message but found %" PRId64 ,
930+ private_data -> n_buffers - 1 , n_buffers );
931931 return EINVAL ;
932932 }
933933
@@ -981,8 +981,9 @@ static inline int ArrowIpcDecoderReadHeaderPrefix(struct ArrowIpcDecoder* decode
981981 (struct ArrowIpcDecoderPrivate * )decoder -> private_data ;
982982
983983 if (data_mut -> size_bytes < kMessageHeaderPrefixSize ) {
984- ArrowErrorSet (error , "Expected data of at least 8 bytes but only %ld bytes remain" ,
985- (long )data_mut -> size_bytes );
984+ ArrowErrorSet (error ,
985+ "Expected data of at least 8 bytes but only %" PRId64 " bytes remain" ,
986+ data_mut -> size_bytes );
986987 return ESPIPE ;
987988 }
988989
@@ -997,9 +998,10 @@ static inline int ArrowIpcDecoderReadHeaderPrefix(struct ArrowIpcDecoder* decode
997998 int32_t header_body_size_bytes = ArrowIpcReadInt32LE (data_mut , swap_endian );
998999 * message_size_bytes = header_body_size_bytes + kMessageHeaderPrefixSize ;
9991000 if (header_body_size_bytes < 0 ) {
1000- ArrowErrorSet (
1001- error , "Expected message body size > 0 but found message body size of %ld bytes" ,
1002- (long )header_body_size_bytes );
1001+ ArrowErrorSet (error ,
1002+ "Expected message body size > 0 but found message body size of %" PRId32
1003+ " bytes" ,
1004+ header_body_size_bytes );
10031005 return EINVAL ;
10041006 }
10051007
@@ -1035,9 +1037,10 @@ ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder,
10351037 int64_t message_body_size = decoder -> header_size_bytes - kMessageHeaderPrefixSize ;
10361038 if (data .size_bytes < message_body_size ) {
10371039 ArrowErrorSet (error ,
1038- "Expected >= %ld bytes of remaining data but found %ld bytes in buffer" ,
1039- (long )message_body_size + kMessageHeaderPrefixSize ,
1040- (long )data .size_bytes + kMessageHeaderPrefixSize );
1040+ "Expected >= %" PRId64 " bytes of remaining data but found %" PRId64
1041+ " bytes in buffer" ,
1042+ message_body_size + kMessageHeaderPrefixSize ,
1043+ data .size_bytes + kMessageHeaderPrefixSize );
10411044 return ESPIPE ;
10421045 }
10431046
@@ -1073,9 +1076,10 @@ ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder,
10731076 int64_t message_body_size = decoder -> header_size_bytes - kMessageHeaderPrefixSize ;
10741077 if (data .size_bytes < message_body_size ) {
10751078 ArrowErrorSet (error ,
1076- "Expected >= %ld bytes of remaining data but found %ld bytes in buffer" ,
1077- (long )message_body_size + kMessageHeaderPrefixSize ,
1078- (long )data .size_bytes + kMessageHeaderPrefixSize );
1079+ "Expected >= %" PRId64 " bytes of remaining data but found %" PRId64
1080+ " bytes in buffer" ,
1081+ message_body_size + kMessageHeaderPrefixSize ,
1082+ data .size_bytes + kMessageHeaderPrefixSize );
10791083 return ESPIPE ;
10801084 }
10811085
@@ -1152,8 +1156,8 @@ ArrowErrorCode ArrowIpcDecoderDecodeSchema(struct ArrowIpcDecoder* decoder,
11521156 int result = ArrowSchemaSetTypeStruct (& tmp , n_fields );
11531157 if (result != NANOARROW_OK ) {
11541158 ArrowSchemaRelease (& tmp );
1155- ArrowErrorSet (error , "Failed to allocate struct schema with %ld children" ,
1156- ( long ) n_fields );
1159+ ArrowErrorSet (error , "Failed to allocate struct schema with %" PRId64 " children" ,
1160+ n_fields );
11571161 return result ;
11581162 }
11591163
@@ -1462,8 +1466,9 @@ static int ArrowIpcDecoderSwapEndian(struct ArrowIpcBufferSource* src,
14621466 break ;
14631467 }
14641468 default :
1465- ArrowErrorSet (error , "Endian swapping for element bitwidth %d is not supported" ,
1466- (int )src -> element_size_bits );
1469+ ArrowErrorSet (
1470+ error , "Endian swapping for element bitwidth %" PRId64 " is not supported" ,
1471+ src -> element_size_bits );
14671472 return ENOTSUP ;
14681473 }
14691474 break ;
@@ -1498,8 +1503,10 @@ static int ArrowIpcDecoderMakeBuffer(struct ArrowIpcArraySetter* setter, int64_t
14981503 int64_t buffer_start = offset ;
14991504 int64_t buffer_end = buffer_start + length ;
15001505 if (buffer_start < 0 || buffer_end > setter -> body_size_bytes ) {
1501- ArrowErrorSet (error , "Buffer requires body offsets [%ld..%ld) but body has size %ld" ,
1502- (long )buffer_start , (long )buffer_end , (long )setter -> body_size_bytes );
1506+ ArrowErrorSet (error ,
1507+ "Buffer requires body offsets [%" PRId64 "..%" PRId64
1508+ ") but body has size %" PRId64 ,
1509+ buffer_start , buffer_end , setter -> body_size_bytes );
15031510 return EINVAL ;
15041511 }
15051512
0 commit comments