Skip to content

Commit

Permalink
[ObjC] Fix up some sign related warnings.
Browse files Browse the repository at this point in the history
The api signatures aren't changed, just internal casting it used
to avoid making an API change which could be considered breaking.

PiperOrigin-RevId: 720300558
  • Loading branch information
thomasvl authored and copybara-github committed Jan 27, 2025
1 parent 5f9fc54 commit 48d83b3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions objectivec/GPBDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ + (instancetype)allocDescriptorForClass:(Class)messageClass
// Compute the unknown flags by this version of the runtime and then check the passed in flags
// (from the generated code) to detect when sources from a newer version are being used with an
// older runtime.
GPBDescriptorInitializationFlags unknownFlags =
~(GPBDescriptorInitializationFlag_FieldsWithDefault |
GPBDescriptorInitializationFlag_WireFormat | GPBDescriptorInitializationFlag_UsesClassRefs |
GPBDescriptorInitializationFlag_Proto3OptionalKnown |
GPBDescriptorInitializationFlag_ClosedEnumSupportKnown);
GPBDescriptorInitializationFlags unknownFlags = (GPBDescriptorInitializationFlags)(~(
GPBDescriptorInitializationFlag_FieldsWithDefault |
GPBDescriptorInitializationFlag_WireFormat | GPBDescriptorInitializationFlag_UsesClassRefs |
GPBDescriptorInitializationFlag_Proto3OptionalKnown |
GPBDescriptorInitializationFlag_ClosedEnumSupportKnown));
if ((flags & unknownFlags) != 0) {
GPBRuntimeMatchFailure();
}
Expand Down Expand Up @@ -144,10 +144,10 @@ + (instancetype)allocDescriptorForClass:(Class)messageClass
}
// No real value in checking all the fields individually, just check the combined flags at the
// end.
GPBFieldFlags unknownFieldFlags =
~(GPBFieldRequired | GPBFieldRepeated | GPBFieldPacked | GPBFieldOptional |
GPBFieldHasDefaultValue | GPBFieldClearHasIvarOnZero | GPBFieldTextFormatNameCustom |
GPBFieldHasEnumDescriptor | GPBFieldMapKeyMask | GPBFieldClosedEnum);
GPBFieldFlags unknownFieldFlags = (GPBFieldFlags)(~(
GPBFieldRequired | GPBFieldRepeated | GPBFieldPacked | GPBFieldOptional |
GPBFieldHasDefaultValue | GPBFieldClearHasIvarOnZero | GPBFieldTextFormatNameCustom |
GPBFieldHasEnumDescriptor | GPBFieldMapKeyMask | GPBFieldClosedEnum));
if ((mergedFieldFlags & unknownFieldFlags) != 0) {
GPBRuntimeMatchFailure();
}
Expand Down Expand Up @@ -203,7 +203,8 @@ - (void)setupOneofs:(const char **)oneofNames
firstHasIndex:(int32_t)firstHasIndex {
NSCAssert(firstHasIndex < 0, @"Should always be <0");
NSMutableArray *oneofs = [[NSMutableArray alloc] initWithCapacity:count];
for (uint32_t i = 0, hasIndex = firstHasIndex; i < count; ++i, --hasIndex) {
int32_t hasIndex = firstHasIndex;
for (uint32_t i = 0; i < count; ++i, --hasIndex) {
const char *name = oneofNames[i];
NSArray *fieldsForOneof = NewFieldsArrayForHasIndex(hasIndex, fields_);
NSCAssert(fieldsForOneof.count > 0, @"No fields for this oneof? (%s:%d)", name, hasIndex);
Expand Down Expand Up @@ -231,7 +232,7 @@ - (void)setupExtraTextInfo:(const char *)extraTextFormatInfo {

- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count {
extensionRanges_ = ranges;
extensionRangesCount_ = count;
extensionRangesCount_ = (uint32_t)count;
}

- (void)setupContainingMessageClass:(Class)messageClass {
Expand Down Expand Up @@ -632,7 +633,7 @@ - (NSString *)textFormatName {
return nil;
}
const uint8_t *extraTextFormatInfo = [extraInfoValue pointerValue];
return GPBDecodeTextFormatName(extraTextFormatInfo, GPBFieldNumber(self), self.name);
return GPBDecodeTextFormatName(extraTextFormatInfo, (int32_t)GPBFieldNumber(self), self.name);
}

// The logic here has to match SetCommonFieldVariables() from
Expand Down Expand Up @@ -714,7 +715,7 @@ + (instancetype)allocDescriptorForName:(NSString *)name
// (from the generated code) to detect when sources from a newer version are being used with an
// older runtime.
GPBEnumDescriptorInitializationFlags unknownFlags =
~(GPBEnumDescriptorInitializationFlag_IsClosed);
(GPBEnumDescriptorInitializationFlags)(~(GPBEnumDescriptorInitializationFlag_IsClosed));
if ((flags & unknownFlags) != 0) {
GPBRuntimeMatchFailure();
}
Expand Down Expand Up @@ -927,8 +928,8 @@ - (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc
// Compute the unknown options by this version of the runtime and then check the passed in
// descriptor's options (from the generated code) to detect when sources from a newer version are
// being used with an older runtime.
GPBExtensionOptions unknownOptions =
~(GPBExtensionRepeated | GPBExtensionPacked | GPBExtensionSetWireFormat);
GPBExtensionOptions unknownOptions = (GPBExtensionOptions)(~(
GPBExtensionRepeated | GPBExtensionPacked | GPBExtensionSetWireFormat));
if ((desc->options & unknownOptions) != 0) {
GPBRuntimeMatchFailure();
}
Expand Down Expand Up @@ -996,7 +997,7 @@ - (const char *)singletonNameC {
}

- (uint32_t)fieldNumber {
return description_->fieldNumber;
return (uint32_t)(description_->fieldNumber);
}

- (GPBDataType)dataType {
Expand Down

0 comments on commit 48d83b3

Please sign in to comment.