Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 9726ae3

Browse files
authored
Merge pull request #65 from openweave/bug/fix-warnings
Address Various Compiler Warnings
2 parents 820c871 + df7d18b commit 9726ae3

26 files changed

+116
-116
lines changed

src/lib/profiles/data-management/Current/MessageDef.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2016-2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -47,6 +48,10 @@
4748

4849
#include <stdio.h>
4950

51+
using namespace ::nl;
52+
using namespace ::nl::Weave;
53+
using namespace ::nl::Weave::TLV;
54+
5055
#ifndef MIN
5156
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
5257
#endif
@@ -2741,13 +2746,19 @@ WEAVE_ERROR StatusList::Parser::CheckSchemaValidity(void) const
27412746

27422747
while (WEAVE_NO_ERROR == (err = reader.Next()))
27432748
{
2749+
TLVType type;
2750+
uint64_t tag;
2751+
27442752
// TODO: The spec says the StatusList should be an array of arrays, but in
27452753
// the current implementation it's an array of structures. The array of
27462754
// arrays is less intuitive but more space efficient.
2747-
VerifyOrExit(nl::Weave::TLV::AnonymousTag == reader.GetTag(), err = WEAVE_ERROR_INVALID_TLV_TAG);
27482755

2749-
VerifyOrExit((nl::Weave::TLV::kTLVType_Structure == reader.GetType() ||
2750-
nl::Weave::TLV::kTLVType_Array), err = WEAVE_ERROR_WRONG_TLV_TYPE);
2756+
tag = reader.GetTag();
2757+
VerifyOrExit(nl::Weave::TLV::AnonymousTag == tag, err = WEAVE_ERROR_INVALID_TLV_TAG);
2758+
2759+
type = reader.GetType();
2760+
VerifyOrExit((nl::Weave::TLV::kTLVType_Structure == type ||
2761+
nl::Weave::TLV::kTLVType_Array == type), err = WEAVE_ERROR_WRONG_TLV_TYPE);
27512762

27522763
{
27532764
StatusElement::Parser status;

src/lib/profiles/data-management/Legacy/ProfileDatabase.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
429429
const uint64_t &aTag,
430430
uint32_t aProfileId,
431431
const uint64_t &aInstanceId,
432-
uint16_t aPathLen,
432+
uint32_t aPathLen,
433433
...)
434434
{
435435
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -451,7 +451,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
451451

452452
va_start(pathTags, aPathLen);
453453

454-
for (int i = 0; i < aPathLen; i++)
454+
for (uint32_t i = 0; i < aPathLen; i++)
455455
{
456456
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
457457

@@ -517,7 +517,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
517517
uint32_t aProfileId,
518518
const uint32_t aInstanceIdLen,
519519
const uint8_t *aInstanceId,
520-
uint16_t aPathLen,
520+
uint32_t aPathLen,
521521
...)
522522
{
523523
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -539,7 +539,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
539539

540540
va_start(pathTags, aPathLen);
541541

542-
for (int i = 0; i < aPathLen; i++)
542+
for (uint32_t i = 0; i < aPathLen; i++)
543543
{
544544
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
545545

@@ -598,7 +598,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
598598
const uint64_t &aTag,
599599
uint32_t aProfileId,
600600
const char *aInstanceId,
601-
uint16_t aPathLen,
601+
uint32_t aPathLen,
602602
...)
603603
{
604604
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -620,7 +620,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
620620

621621
va_start(pathTags, aPathLen);
622622

623-
for (int i = 0; i < aPathLen; i++)
623+
for (uint32_t i = 0; i < aPathLen; i++)
624624
{
625625
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
626626

@@ -679,7 +679,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
679679
const uint64_t &aTag,
680680
uint32_t aProfileId,
681681
const uint64_t &aInstanceId,
682-
uint16_t aPathLen,
682+
uint32_t aPathLen,
683683
...)
684684
{
685685
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -709,7 +709,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
709709

710710
va_start(pathTags, aPathLen);
711711

712-
for (int i = 0; i < aPathLen; i++)
712+
for (uint32_t i = 0; i < aPathLen; i++)
713713
{
714714
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
715715

@@ -768,7 +768,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
768768
const uint64_t &aTag,
769769
uint32_t aProfileId,
770770
const char *aInstanceId,
771-
uint16_t aPathLen,
771+
uint32_t aPathLen,
772772
...)
773773
{
774774
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -798,7 +798,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
798798

799799
va_start(pathTags, aPathLen);
800800

801-
for (int i = 0; i < aPathLen; i++)
801+
for (uint32_t i = 0; i < aPathLen; i++)
802802
{
803803
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
804804

src/lib/profiles/data-management/Legacy/ProfileDatabase.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,22 +386,22 @@ namespace WeaveMakeManagedNamespaceIdentifier(DataManagement, kWeaveManagedNames
386386
const uint64_t &aTag,
387387
uint32_t aProfileId,
388388
const uint64_t &aInstanceId,
389-
uint16_t aPathLen,
389+
uint32_t aPathLen,
390390
...);
391391

392392
WEAVE_ERROR EncodePath(nl::Weave::TLV::TLVWriter &aWriter,
393393
const uint64_t &aTag,
394394
uint32_t aProfileId,
395395
const uint32_t aInstanceIdLen,
396396
const uint8_t *aInstanceId,
397-
uint16_t aPathLen,
397+
uint32_t aPathLen,
398398
...);
399399

400400
WEAVE_ERROR EncodePath(nl::Weave::TLV::TLVWriter &aWriter,
401401
const uint64_t &aTag,
402402
uint32_t aProfileId,
403403
const char *aInstanceId,
404-
uint16_t aPathLen,
404+
uint32_t aPathLen,
405405
...);
406406

407407
/*
@@ -414,14 +414,14 @@ namespace WeaveMakeManagedNamespaceIdentifier(DataManagement, kWeaveManagedNames
414414
const uint64_t &aTag,
415415
uint32_t aProfileId,
416416
const uint64_t &aInstanceId,
417-
uint16_t aPathLen,
417+
uint32_t aPathLen,
418418
...);
419419

420420
WEAVE_ERROR EncodeDeprecatedPath(nl::Weave::TLV::TLVWriter &aWriter,
421421
const uint64_t &aTag,
422422
uint32_t aProfileId,
423423
const char *aInstanceId,
424-
uint16_t aPathLen,
424+
uint32_t aPathLen,
425425
...);
426426

427427
/**

src/test-apps/MockEvents.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -59,6 +60,14 @@ using namespace Schema::Nest::Test::Trait::TestETrait;
5960
using namespace Schema::Nest::Test::Trait;
6061
using namespace Schema::Weave::Common;
6162

63+
#ifdef PHOENIX_RESOURCE_STRINGS
64+
#define USER_ID_INITIAL NULL
65+
static uint8_t kTestUserId[1] = { 1 };
66+
#else
67+
#define USER_ID_INITIAL 0
68+
static const user_id_t kTestUserId = 0x0123456789ULL;
69+
#endif /* PHOENIX_RESOURCE_STRINGS */
70+
6271
static const uint64_t kTestNodeId = 0x18B4300001408362ULL;
6372
static const uint64_t kTestNodeId1 = 0x18B43000002DCF71ULL;
6473

@@ -299,21 +308,22 @@ const uint64_t kbolt_lock_actor_method = nl::Weave::TLV::Con
299308
const uint64_t kbolt_lock_actor_user_id = nl::Weave::TLV::ContextTag(2);
300309

301310
BoltActuatorEventStruct::BoltActuatorEventStruct() :
302-
locked_state_last_changed_at(0),
303311
state(0),
304312
actuatorState(0),
305313
lockedState(0),
306-
bolt_lock_actor()
314+
bolt_lock_actor(),
315+
locked_state_last_changed_at(0)
307316
{
317+
return;
308318
}
309319

310320
BoltLockActorStruct::BoltLockActorStruct() :
311-
user_id(USER_ID_INITIAL),
312-
method(0)
321+
method(0),
322+
user_id(USER_ID_INITIAL)
313323
{
324+
return;
314325
}
315326

316-
317327
static WEAVE_ERROR WriteBoltActuatorStateChangeEvent(nl::Weave::TLV::TLVWriter & writer, uint8_t inDataTag, void * anAppState)
318328
{
319329
WEAVE_ERROR err = WEAVE_NO_ERROR;

src/test-apps/MockEvents.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2016-2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -45,17 +46,12 @@
4546
// Several event definitions, hand generated at this time
4647

4748
#define PHOENIX_RESOURCE_STRINGS
49+
4850
#ifdef PHOENIX_RESOURCE_STRINGS
4951
typedef uint8_t * user_id_t;
50-
#define USER_ID_INITIAL NULL
51-
static uint8_t kTestUserId[1] = { 1 };
5252
#else
5353
typedef uint64_t user_id_t;
54-
#define USER_ID_INITIAL 0
55-
static const user_id_t kTestUserId = 0x0123456789ULL;
56-
57-
#endif
58-
54+
#endif /* PHOENIX_RESOURCE_STRINGS */
5955

6056
/************************************************************************/
6157

@@ -233,14 +229,16 @@ enum BoltLockedState {
233229

234230
struct BoltLockActorStruct
235231
{
236-
BoltLockActorStruct();
232+
BoltLockActorStruct(void);
233+
237234
int16_t method;
238235
user_id_t user_id;
239236
};
240237

241238
struct BoltActuatorEventStruct
242239
{
243-
BoltActuatorEventStruct();
240+
BoltActuatorEventStruct(void);
241+
244242
int16_t state;
245243
int16_t actuatorState;
246244
int16_t lockedState;

src/test-apps/MockSinkTraits.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2016-2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -520,7 +521,9 @@ TestATraitDataSink::SetData(PropertyPathHandle aHandle, TLVReader &aReader, bool
520521
}
521522
}
522523

524+
#if TDM_DISABLE_STRICT_SCHEMA_COMPLIANCE == 0
523525
exit:
526+
#endif
524527
return err;
525528
}
526529

@@ -2121,7 +2124,10 @@ TestATraitUpdatableDataSink::SetData(PropertyPathHandle aHandle, TLVReader &aRea
21212124
aHandle = mSchemaEngine->GetParent(aHandle);
21222125
}
21232126
}
2124-
exit:
2127+
2128+
#if TDM_DISABLE_STRICT_SCHEMA_COMPLIANCE == 0
2129+
exit:
2130+
#endif
21252131
return err;
21262132
}
21272133

src/test-apps/MockWdmNodeOptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2018 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -515,7 +516,7 @@ bool MockWdmNodeOptions::HandleOption(const char *progName, OptionSet *optSet, i
515516
}
516517
case kToolOpt_WdmUpdateNumberOfTraits:
517518
{
518-
int tmp;
519+
uint32_t tmp;
519520

520521
if ((!ParseInt(arg, tmp)) || (tmp < 1) || (tmp > mWdmUpdateMaxNumberOfTraits))
521522
{

src/test-apps/MockWdmSubscriptionInitiator.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2016-2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -102,23 +103,6 @@ class WdmInitiatorState
102103

103104
static WdmInitiatorState gInitiatorState;
104105

105-
static void TLVPrettyPrinter(const char *aFormat, ...)
106-
{
107-
va_list args;
108-
109-
va_start(args, aFormat);
110-
111-
// There is no proper Weave logging routine for us to use here
112-
vprintf(aFormat, args);
113-
114-
va_end(args);
115-
}
116-
117-
static WEAVE_ERROR DebugPrettyPrint(nl::Weave::TLV::TLVReader & aReader)
118-
{
119-
return nl::Weave::TLV::Debug::Dump(aReader, TLVPrettyPrinter);
120-
}
121-
122106
namespace nl {
123107
namespace Weave {
124108
namespace Profiles {

src/test-apps/TestDataManagement.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ static OptionSet *gToolOptionSets[] =
151151
} \
152152
} while (0)
153153

154-
WEAVE_ERROR ValidatePath(TLVReader &aReader,
155-
const uint64_t &aTag,
156-
uint32_t aProfileId,
157-
const uint64_t &aInstanceId,
158-
uint16_t aPathLen,
159-
...)
154+
static WEAVE_ERROR ValidatePath(TLVReader &aReader,
155+
const uint64_t &aTag,
156+
uint32_t aProfileId,
157+
const uint64_t &aInstanceId,
158+
uint32_t aPathLen,
159+
...)
160160
{
161161
WEAVE_ERROR err;
162162

@@ -237,7 +237,7 @@ WEAVE_ERROR ValidatePath(TLVReader &aReader,
237237

238238
// now, the residual path elements, if any
239239

240-
for (int i = 0; i < aPathLen; i++)
240+
for (uint32_t i = 0; i < aPathLen; i++)
241241
{
242242
err = aReader.Next();
243243
SuccessOrExit(err);
@@ -276,22 +276,6 @@ WEAVE_ERROR ValidatePath(TLVReader &aReader,
276276
return err;
277277
}
278278

279-
/*
280-
* one day we might want to include the other form of instance ID
281-
* in testing. for now just leave this as a placeholder.
282-
*/
283-
284-
WEAVE_ERROR ValidatePath(nl::Weave::TLV::TLVReader &aReader,
285-
const uint64_t &aTag,
286-
uint32_t aProfileId,
287-
uint32_t aInstanceIdLen,
288-
uint8_t *aInstanceId,
289-
uint16_t aPathLen,
290-
...)
291-
{
292-
return WEAVE_NO_ERROR;
293-
}
294-
295279
/*
296280
* in order to use the "new improved" data management, we have to create
297281
* a sub-class of the WDM client and supply the relevant methods as follows.

0 commit comments

Comments
 (0)