[Gptfdisk-general] [PATCH 05/15] gptcl: Silence the compiler warning in BuildMBR()
Brought to you by:
srs5694
|
From: Bin M. <bme...@gm...> - 2022-04-02 07:00:45
|
When built with -O2 flag, there is a compiler warning:
gptcl.cc: In member function 'int GPTDataCL::BuildMBR(char*, int)':
gptcl.cc:507:8: warning: 'eeLast' may be used uninitialized in this
function [-Wmaybe-uninitialized]
507 | int eeLast, mbrNum = 0;
| ^~~~~~
The code logic is correct despite the warning. The warning can be
silenced by initializing the local variable.
Signed-off-by: Bin Meng <bme...@gm...>
---
gptcl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gptcl.cc b/gptcl.cc
index 3995093..0141994 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -504,7 +504,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
// Create a hybrid or regular MBR from GPT data structures
int GPTDataCL::BuildMBR(char* argument, int isHybrid) {
int numParts, allOK = 1, i, origPartNum;
- int eeLast, mbrNum = 0;
+ int eeLast = 0, mbrNum = 0;
MBRPart newPart;
BasicMBRData newMBR;
--
2.25.1
|