Skip to content

Commit 2e645ce

Browse files
committed
Use portable formats from omrformatconsts.h
* eliminates numerous '-Wformat' warnings Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
1 parent c757b51 commit 2e645ce

11 files changed

+211
-203
lines changed

runtime/compiler/codegen/CodeGenGPU.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "env/annotations/GPUAnnotation.hpp"
4545
#include "optimizer/Dominators.hpp"
4646
#include "optimizer/Structure.hpp"
47+
#include "omrformatconsts.h"
4748

4849
#define OPT_DETAILS "O^O CODE GENERATION: "
4950

@@ -576,7 +577,7 @@ static void getParmName(int32_t slot, char * s, bool addr = true)
576577
{
577578
int32_t len = 0;
578579

579-
len = snprintf(s, MAX_NAME, "%%p%d%s", slot, addr ? ".addr" : "");
580+
len = snprintf(s, MAX_NAME, "%%p%" OMR_PRId32 "%s", slot, addr ? ".addr" : "");
580581

581582
TR_ASSERT(len < MAX_NAME, "Auto's or parm's name is too long\n");
582583
}
@@ -588,9 +589,9 @@ static void getAutoOrParmName(TR::Symbol *sym, char * s, bool addr = true)
588589
TR_ASSERT(sym->isAutoOrParm(), "expecting auto or parm");
589590

590591
if (sym->isParm())
591-
len = snprintf(s, MAX_NAME, "%%p%d%s", sym->castToParmSymbol()->getSlot(), addr ? ".addr" : "");
592+
len = snprintf(s, MAX_NAME, "%%p%" OMR_PRId32 "%s", sym->castToParmSymbol()->getSlot(), addr ? ".addr" : "");
592593
else
593-
len = snprintf(s, MAX_NAME, "%%a%d%s", sym->castToAutoSymbol()->getLiveLocalIndex(), addr ? ".addr" : "");
594+
len = snprintf(s, MAX_NAME, "%%a%" OMR_PRId32 "%s", sym->castToAutoSymbol()->getLiveLocalIndex(), addr ? ".addr" : "");
594595

595596
TR_ASSERT(len < MAX_NAME, "Auto's or parm's name is too long\n");
596597
}
@@ -661,24 +662,24 @@ static void getNodeName(TR::Node* node, char * s, TR::Compilation *comp)
661662
{
662663
case TR::Int8:
663664
if(isUnsigned)
664-
len = snprintf(s, MAX_NAME, "%u", node->getUnsignedByte());
665+
len = snprintf(s, MAX_NAME, "%" OMR_PRIu8, node->getUnsignedByte());
665666
else
666-
len = snprintf(s, MAX_NAME, "%d", node->getByte());
667+
len = snprintf(s, MAX_NAME, "%" OMR_PRId8, node->getByte());
667668
break;
668669
case TR::Int16:
669-
len = snprintf(s, MAX_NAME, "%d", node->getConst<uint16_t>());
670+
len = snprintf(s, MAX_NAME, "%" OMR_PRIu16, node->getConst<uint16_t>());
670671
break;
671672
case TR::Int32:
672673
if(isUnsigned)
673-
len = snprintf(s, MAX_NAME, "%u", node->getUnsignedInt());
674+
len = snprintf(s, MAX_NAME, "%" OMR_PRIu32, node->getUnsignedInt());
674675
else
675-
len = snprintf(s, MAX_NAME, "%d", node->getInt());
676+
len = snprintf(s, MAX_NAME, "%" OMR_PRId32, node->getInt());
676677
break;
677678
case TR::Int64:
678679
if(isUnsigned)
679-
len = snprintf(s, MAX_NAME, UINT64_PRINTF_FORMAT, node->getUnsignedLongInt());
680+
len = snprintf(s, MAX_NAME, "%" OMR_PRIu64, node->getUnsignedLongInt());
680681
else
681-
len = snprintf(s, MAX_NAME, INT64_PRINTF_FORMAT, node->getLongInt());
682+
len = snprintf(s, MAX_NAME, "%" OMR_PRId64, node->getLongInt());
682683
break;
683684
case TR::Float:
684685
union
@@ -687,10 +688,10 @@ static void getNodeName(TR::Node* node, char * s, TR::Compilation *comp)
687688
int64_t doubleBits;
688689
};
689690
doubleValue = node->getFloat();
690-
len = snprintf(s, MAX_NAME, "0x%0.16llx", doubleBits);
691+
len = snprintf(s, MAX_NAME, "0x%016" OMR_PRIx64, doubleBits);
691692
break;
692693
case TR::Double:
693-
len = snprintf(s, MAX_NAME, "0x%0.16llx", node->getDoubleBits());
694+
len = snprintf(s, MAX_NAME, "0x%016" OMR_PRIx64, node->getDoubleBits());
694695
break;
695696
case TR::Address:
696697
if (node->getAddress() == 0)
@@ -704,7 +705,7 @@ static void getNodeName(TR::Node* node, char * s, TR::Compilation *comp)
704705
}
705706
else
706707
{
707-
len = snprintf(s, MAX_NAME, "%%%d", node->getLocalIndex());
708+
len = snprintf(s, MAX_NAME, "%%%" OMR_PRIu32, node->getLocalIndex());
708709
}
709710

710711
TR_ASSERT(len < MAX_NAME, "Node's name is too long\n");
@@ -1332,7 +1333,7 @@ J9::CodeGenerator::printNVVMIR(
13321333
}
13331334
else
13341335
{
1335-
int32_t len = snprintf(name0, MAX_NAME, "%d", smsize);
1336+
int32_t len = snprintf(name0, MAX_NAME, "%" OMR_PRId32, smsize);
13361337
TR_ASSERT(len < MAX_NAME, "Node's name is too long\n");
13371338
}
13381339

@@ -2861,4 +2862,3 @@ J9::CodeGenerator::objectHeaderInvariant()
28612862
{
28622863
return self()->objectLengthOffset() + 4 /*length*/ ;
28632864
}
2864-

runtime/compiler/env/annotations/TestAnnotation.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2019 IBM Corp. and others
2+
* Copyright (c) 2000, 2020 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -29,6 +29,7 @@
2929
#include "il/Symbol.hpp"
3030
#include "il/SymbolReference.hpp"
3131
#include "compile/ResolvedMethod.hpp"
32+
#include "omrformatconsts.h"
3233

3334
// only purpose of this class is to test that annotations are working. Will
3435
// expect specific values
@@ -55,35 +56,35 @@ TR_TestAnnotation::TR_TestAnnotation(TR::Compilation *comp,TR::SymbolReference *
5556
J9SRP *strPtr;
5657
if(getValue(symRef,"intField",kInt,&intptr))
5758
{
58-
printf("Found int value %d\n",*intptr);
59+
printf("Found int value %" OMR_PRId32 "\n", *intptr);
5960
}
6061
if(getValue(symRef,"floatField",kFloat,&fltptr))
6162
{
6263
printf("Found float value %f\n",*fltptr);
6364
}
6465
if(getValue(symRef,"booleanField",kBool,&intptr))
6566
{
66-
printf("Found boolean value %d\n",*intptr);
67+
printf("Found boolean value %" OMR_PRId32 "\n", *intptr);
6768
}
6869
if(getValue(symRef,"doubleField",kDouble,&dblptr))
6970
{
7071
printf("Found dbl value %e\n",*dblptr);
7172
}
7273
if(getValue(symRef,"charField",kChar,&intptr))
7374
{
74-
printf("Found char value %d\n",*intptr);
75+
printf("Found char value %" OMR_PRId32 "\n", *intptr);
7576
}
7677
if(getValue(symRef,"shortField",kShort,&intptr))
7778
{
78-
printf("Found short value %d\n",*intptr);
79+
printf("Found short value %" OMR_PRId32 "\n", *intptr);
7980
}
8081
if(getValue(symRef,"byteField",kByte,&intptr))
8182
{
82-
printf("Found byte value %d\n",*intptr);
83+
printf("Found byte value %" OMR_PRId32 "\n", *intptr);
8384
}
8485
if(getValue(symRef,"longField",kLong,&longptr))
8586
{
86-
printf("Found byte value %lld\n",*longptr);
87+
printf("Found long value %" OMR_PRId64 "\n", *longptr);
8788
}
8889
char *enumerationName=NULL, *enumerationValue=NULL;
8990
int32_t nameLen,valueLen;
@@ -110,5 +111,3 @@ TR_TestAnnotation::TR_TestAnnotation(TR::Compilation *comp,TR::SymbolReference *
110111

111112
_isValid=true;
112113
}
113-
114-

runtime/compiler/optimizer/IdiomRecognition.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "optimizer/TransformUtil.hpp"
7070
#include "optimizer/UseDefInfo.hpp"
7171
#include "ras/Debug.hpp"
72+
#include "omrformatconsts.h"
7273

7374
#define OPT_DETAILS "O^O NEWLOOPREDUCER: "
7475
#define VERBOSE 0
@@ -5207,11 +5208,11 @@ TR_CISCTransformer::extractMatchingRegion()
52075208
isEmbed = false;
52085209
if (showMesssagesStdout())
52095210
{
5210-
printf("!!!!!!!!!!!!!! Predecessor of tID %d is different from that of idiom.\n",tID);
5211+
printf("!!!!!!!!!!!!!! Predecessor of tID %" OMR_PRIu32 " is different from that of idiom.\n", tID);
52115212
}
52125213
if (trace())
52135214
{
5214-
traceMsg(comp(), "Predecessor of tID %d is different from that of idiom.\n",tID);
5215+
traceMsg(comp(), "Predecessor of tID %" OMR_PRIu32 " is different from that of idiom.\n", tID);
52155216
}
52165217
}
52175218
}
@@ -7616,13 +7617,13 @@ TR_CISCTransformer::computeTopologicalEmbedding(TR_CISCGraph *P, TR_CISCGraph *T
76167617
bool inlined = getBCIndexMinMax(_candidateRegion, &minIndex, &maxIndex, &minLN, &maxLN, true);
76177618
if (minIndex <= maxIndex)
76187619
{
7619-
sprintf(tmpbuf, ", bcindex %d - %d linenumber %d - %d%s.", minIndex, maxIndex, minLN, maxLN, inlined ? " (inlined)" : "");
7620+
sprintf(tmpbuf, ", bcindex %" OMR_PRIu32 " - %" OMR_PRIu32 " linenumber %" OMR_PRIu32 " - %" OMR_PRIu32 "%s.", minIndex, maxIndex, minLN, maxLN, inlined ? " (inlined)" : "");
76207621
bcinfo = tmpbuf;
76217622
}
76227623
#endif
76237624
#if SHOW_STATISTICS
76247625
if (showMesssagesStdout())
7625-
printf("!! Hash=0x%llx %s %s\n", getHashValue(_candidateRegion), P->getTitle(), T->getTitle());
7626+
printf("!! Hash=0x%" OMR_PRIx64 " %s %s\n", getHashValue(_candidateRegion), P->getTitle(), T->getTitle());
76267627
#endif
76277628

76287629
if (trace()) traceMsg(comp(), "***** Transformed *****, %s, %s, %s, loop:%d%s\n",
@@ -7837,7 +7838,7 @@ TR_CISCTransformer::insertBitsKeepAliveCalls(TR::Block * block)
78377838
{
78387839
TR::TreeTop * prev = info->_prevTreeTop;
78397840
TR::Block * keepAliveBlock = info->_block;
7840-
traceMsg(comp(), "\t\tInserting KeepAlive call clone node: %p from block %d [%p] node: %p into block :%d %p\n",callNode, keepAliveBlock->getNumber(), keepAliveBlock, tt->getNode(), block->getNumber(), block);
7841+
traceMsg(comp(), "\t\tInserting KeepAlive call clone node: %p from block %d [%p] node: %p into block: %d %p\n", callNode, keepAliveBlock->getNumber(), keepAliveBlock, tt->getNode(), block->getNumber(), block);
78417842
}
78427843
}
78437844
}
@@ -7861,4 +7862,3 @@ TR_CISCTransformer::restoreBitsKeepAliveCalls()
78617862
prev->insertAfter(tt);
78627863
}
78637864
}
7864-

0 commit comments

Comments
 (0)