Skip to content

Commit 9d46ee5

Browse files
thomasvlcopybara-github
authored andcommitted
[ObjC] Fix up some sign related warnings.
The api signatures aren't changed, just internal casting it used to avoid making an API change which could be considered breaking. PiperOrigin-RevId: 720547989
1 parent 6d2f6fc commit 9d46ee5

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

objectivec/GPBDescriptor.m

+17-16
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ + (instancetype)allocDescriptorForClass:(Class)messageClass
100100
// Compute the unknown flags by this version of the runtime and then check the passed in flags
101101
// (from the generated code) to detect when sources from a newer version are being used with an
102102
// older runtime.
103-
GPBDescriptorInitializationFlags unknownFlags =
104-
~(GPBDescriptorInitializationFlag_FieldsWithDefault |
105-
GPBDescriptorInitializationFlag_WireFormat | GPBDescriptorInitializationFlag_UsesClassRefs |
106-
GPBDescriptorInitializationFlag_Proto3OptionalKnown |
107-
GPBDescriptorInitializationFlag_ClosedEnumSupportKnown);
103+
GPBDescriptorInitializationFlags unknownFlags = (GPBDescriptorInitializationFlags)(~(
104+
GPBDescriptorInitializationFlag_FieldsWithDefault |
105+
GPBDescriptorInitializationFlag_WireFormat | GPBDescriptorInitializationFlag_UsesClassRefs |
106+
GPBDescriptorInitializationFlag_Proto3OptionalKnown |
107+
GPBDescriptorInitializationFlag_ClosedEnumSupportKnown));
108108
if ((flags & unknownFlags) != 0) {
109109
GPBRuntimeMatchFailure();
110110
}
@@ -144,10 +144,10 @@ + (instancetype)allocDescriptorForClass:(Class)messageClass
144144
}
145145
// No real value in checking all the fields individually, just check the combined flags at the
146146
// end.
147-
GPBFieldFlags unknownFieldFlags =
148-
~(GPBFieldRequired | GPBFieldRepeated | GPBFieldPacked | GPBFieldOptional |
149-
GPBFieldHasDefaultValue | GPBFieldClearHasIvarOnZero | GPBFieldTextFormatNameCustom |
150-
GPBFieldHasEnumDescriptor | GPBFieldMapKeyMask | GPBFieldClosedEnum);
147+
GPBFieldFlags unknownFieldFlags = (GPBFieldFlags)(~(
148+
GPBFieldRequired | GPBFieldRepeated | GPBFieldPacked | GPBFieldOptional |
149+
GPBFieldHasDefaultValue | GPBFieldClearHasIvarOnZero | GPBFieldTextFormatNameCustom |
150+
GPBFieldHasEnumDescriptor | GPBFieldMapKeyMask | GPBFieldClosedEnum));
151151
if ((mergedFieldFlags & unknownFieldFlags) != 0) {
152152
GPBRuntimeMatchFailure();
153153
}
@@ -203,7 +203,8 @@ - (void)setupOneofs:(const char **)oneofNames
203203
firstHasIndex:(int32_t)firstHasIndex {
204204
NSCAssert(firstHasIndex < 0, @"Should always be <0");
205205
NSMutableArray *oneofs = [[NSMutableArray alloc] initWithCapacity:count];
206-
for (uint32_t i = 0, hasIndex = firstHasIndex; i < count; ++i, --hasIndex) {
206+
int32_t hasIndex = firstHasIndex;
207+
for (uint32_t i = 0; i < count; ++i, --hasIndex) {
207208
const char *name = oneofNames[i];
208209
NSArray *fieldsForOneof = NewFieldsArrayForHasIndex(hasIndex, fields_);
209210
NSCAssert(fieldsForOneof.count > 0, @"No fields for this oneof? (%s:%d)", name, hasIndex);
@@ -231,7 +232,7 @@ - (void)setupExtraTextInfo:(const char *)extraTextFormatInfo {
231232

232233
- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count {
233234
extensionRanges_ = ranges;
234-
extensionRangesCount_ = count;
235+
extensionRangesCount_ = (uint32_t)count;
235236
}
236237

237238
- (void)setupContainingMessageClass:(Class)messageClass {
@@ -632,7 +633,7 @@ - (NSString *)textFormatName {
632633
return nil;
633634
}
634635
const uint8_t *extraTextFormatInfo = [extraInfoValue pointerValue];
635-
return GPBDecodeTextFormatName(extraTextFormatInfo, GPBFieldNumber(self), self.name);
636+
return GPBDecodeTextFormatName(extraTextFormatInfo, (int32_t)GPBFieldNumber(self), self.name);
636637
}
637638

638639
// The logic here has to match SetCommonFieldVariables() from
@@ -714,7 +715,7 @@ + (instancetype)allocDescriptorForName:(NSString *)name
714715
// (from the generated code) to detect when sources from a newer version are being used with an
715716
// older runtime.
716717
GPBEnumDescriptorInitializationFlags unknownFlags =
717-
~(GPBEnumDescriptorInitializationFlag_IsClosed);
718+
(GPBEnumDescriptorInitializationFlags)(~(GPBEnumDescriptorInitializationFlag_IsClosed));
718719
if ((flags & unknownFlags) != 0) {
719720
GPBRuntimeMatchFailure();
720721
}
@@ -927,8 +928,8 @@ - (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc
927928
// Compute the unknown options by this version of the runtime and then check the passed in
928929
// descriptor's options (from the generated code) to detect when sources from a newer version are
929930
// being used with an older runtime.
930-
GPBExtensionOptions unknownOptions =
931-
~(GPBExtensionRepeated | GPBExtensionPacked | GPBExtensionSetWireFormat);
931+
GPBExtensionOptions unknownOptions = (GPBExtensionOptions)(~(
932+
GPBExtensionRepeated | GPBExtensionPacked | GPBExtensionSetWireFormat));
932933
if ((desc->options & unknownOptions) != 0) {
933934
GPBRuntimeMatchFailure();
934935
}
@@ -996,7 +997,7 @@ - (const char *)singletonNameC {
996997
}
997998

998999
- (uint32_t)fieldNumber {
999-
return description_->fieldNumber;
1000+
return (uint32_t)(description_->fieldNumber);
10001001
}
10011002

10021003
- (GPBDataType)dataType {

0 commit comments

Comments
 (0)