Skip to content

Commit

Permalink
Fix compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchisnall committed Apr 1, 2019
1 parent 50493c3 commit 369c84d
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Test/AssociatedObject2.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ int main()
tc = [MLTestClass new];
objc_setAssociatedObject(tc, &static_char, (id)1223, OBJC_ASSOCIATION_ASSIGN);
[tc release];
int i = 0;
tc = [MLTestClass new];
objc_setAssociatedObject(tc, &static_char, (id)1223, OBJC_ASSOCIATION_ASSIGN);
SEL some_sel = sel_registerName(".some_sel");
const char *types = "v@:";
class_addMethod(object_getClass(tc), some_sel,
(IMP)ff, types);
int j = (int)objc_getAssociatedObject(tc, &static_char);
assert(j == 1223);
[tc release];
}
1 change: 1 addition & 0 deletions Test/ExceptionTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ int finally(void)
{
__attribute__((cleanup(runCleanup)))
int x;
(void)x;
@try { throw(); }
@finally { finallyEntered = YES; }
return 0;
Expand Down
6 changes: 4 additions & 2 deletions Test/IVarSuperclassOverlap.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char *argv[])
Ivar b1 = class_getInstanceVariable(swb, "b1");
Ivar b2 = class_getInstanceVariable(swb, "b2");
Ivar b3 = class_getInstanceVariable(swb, "b3");
Ivar b4 = class_getInstanceVariable(swb, "b3");
Ivar b4 = class_getInstanceVariable(swb, "b4");
Ivar notBitfield = class_getInstanceVariable(swb, "notBitfield");
assert(baseSmall);
assert(c1);
Expand All @@ -53,6 +53,8 @@ int main(int argc, char *argv[])
assert(b1);
assert(b2);
assert(b3);
assert(b4);
assert(notBitfield);
StartsWithBitfield *swbi = [StartsWithBitfield new];

// Alternating 01 bit pattern, should catch small overwrites.
Expand All @@ -77,8 +79,8 @@ int main(int argc, char *argv[])
assert(swbi->b3 == 5);
assert(swbi->b4 == 11);

ptrdiff_t baseSmallOffset = ivar_getOffset(baseSmall);
#ifdef NEW_ABI
ptrdiff_t baseSmallOffset = ivar_getOffset(baseSmall);
// These should pass with the old ABI, but they don't at the moment. The
// way that they don't is not very harmful though: we just get a bit of
// redundant padding, so I don't consider a fix a very high priority.
Expand Down
4 changes: 4 additions & 0 deletions Test/ManyManySelectors.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
static id x(id self, SEL _cmd)
{
methodCalled = YES;
if (strcmp(selBuffer, sel_getName(_cmd)) != 0)
{
fprintf(stderr, "'%s' != '%s'\n", selBuffer, sel_getName(_cmd));
}
assert(strcmp(selBuffer, sel_getName(_cmd)) == 0);
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion Test/PropertyAttributeTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (void)setClsProp: (id)arg {}

int main()
{
unsigned int outCount, i;
unsigned int outCount;
objc_property_t *properties = class_copyPropertyList([helloclass class], &outCount);
assert(outCount == 1);
objc_property_t property = properties[0];
Expand Down
1 change: 1 addition & 0 deletions Test/ProtocolCreation.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void checkProtocolMethod(Protocol *p, SEL sel, BOOL isClass, BOOL isOptional)

int main(void)
{
__attribute__((unused))
Protocol *force_reference = @protocol(Test2);
Protocol *p = objc_allocateProtocol("Test");
protocol_addMethodDescription(p, @selector(someClassMethod), "@:", YES, NO);
Expand Down
5 changes: 0 additions & 5 deletions Test/setSuperclass.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ - (int)onlyExistsOnFinalSuperclass { return 500; }
} while(0)

int main(int argc, char **argv) {
Class firstSuperclass = objc_getClass("DefaultSuperclass");
Class subclass1 = objc_getClass("Subclass1");

/* Transitioning to a new superclass before +initialize has been called */
{
Class subclass1 = objc_getClass("Subclass1");
Expand Down Expand Up @@ -232,8 +229,6 @@ int main(int argc, char **argv) {
class_setSuperclass(subclass2, secondSuperclass);
assert(_notInitializedSuperclass2Initialized);

Subclass2 *subclass2instance2 = class_createInstance(subclass2, 0);

// CLASS
// can call method on subclass
expect([subclass2instance1 existsOnSubclass2]);
Expand Down
1 change: 0 additions & 1 deletion Test/zeroSizedIVar.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ int main()
assert(class_getInstanceSize(nsarray) == (sizeof(Class) + sizeof(NSUInteger)));
Ivar count = class_getInstanceVariable(nsarray, "count");
assert(ivar_getOffset(count) == sizeof(id));
Ivar objects = class_getInstanceVariable(nsarray, "objects");

Class bitfield = objc_getClass("BitfieldTest");
assert(bitfield);
Expand Down
5 changes: 0 additions & 5 deletions arc.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ - (void)release;
return tls;
#endif
}
static int count = 0;
static int poolCount = 0;
static inline void release(id obj);

/**
Expand Down Expand Up @@ -151,7 +149,6 @@ static void emptyPool(struct arc_tls *tls, id *stop)
// This may autorelease some other objects, so we have to work in
// the case where the autorelease pool is extended during a -release.
release(*tls->pool->insert);
count--;
}
void *old = tls->pool;
tls->pool = tls->pool->previous;
Expand All @@ -163,7 +160,6 @@ static void emptyPool(struct arc_tls *tls, id *stop)
(tls->pool->insert > tls->pool->pool))
{
tls->pool->insert--;
count--;
release(*tls->pool->insert);
}
}
Expand Down Expand Up @@ -405,7 +401,6 @@ static inline id autorelease(id obj)
pool->insert = pool->pool;
tls->pool = pool;
}
count++;
*pool->insert = obj;
pool->insert++;
return obj;
Expand Down
5 changes: 4 additions & 1 deletion encoding2.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ void method_getArgumentType(Method method,
const char *types = findParameterStart(method_getTypeEncoding(method), index);
if (NULL == types)
{
strncpy(dst, "", dst_len);
if (dst_len > 0)
{
*dst = '\0';
}
return;
}
size_t length = lengthOfTypeEncoding(types);
Expand Down
2 changes: 0 additions & 2 deletions ivar.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ptrdiff_t objc_sizeof_type(const char *);

PRIVATE void objc_compute_ivar_offsets(Class class)
{
struct objc_ivar_list_legacy *legacy = NULL;
if (class->ivars == NULL)
{
Class super_class = class_getSuperclass(class);
Expand Down Expand Up @@ -47,7 +46,6 @@ PRIVATE void objc_compute_ivar_offsets(Class class)
}
ivar_start = super->instance_size;
}
long class_size = 0 - class->instance_size;
class->instance_size = ivar_start;
/* For each instance variable, we add the offset if required (it will be zero
* if this class is compiled with a static ivar layout). We then set the
Expand Down
2 changes: 1 addition & 1 deletion ivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct objc_ivar_list
* `objc_ivar` structs, which have fields appended that this version of the
* runtime does not know about.
*/
static struct objc_ivar *ivar_at_index(struct objc_ivar_list *l, int i)
static inline struct objc_ivar *ivar_at_index(struct objc_ivar_list *l, int i)
{
assert(l->size >= sizeof(struct objc_ivar));
return (struct objc_ivar*)(((char*)l->ivar_list) + (i * l->size));
Expand Down
1 change: 0 additions & 1 deletion loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ OBJC_PUBLIC void __objc_load(struct objc_init *init)
}
objc_register_selector(sel);
}
int i = 0;
for (struct objc_protocol *proto = init->proto_begin ; proto < init->proto_end ;
proto++)
{
Expand Down
2 changes: 1 addition & 1 deletion method.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct objc_method_list
* `objc_method` structs, which have fields appended that this version of the
* runtime does not know about.
*/
static struct objc_method *method_at_index(struct objc_method_list *l, int i)
static inline struct objc_method *method_at_index(struct objc_method_list *l, int i)
{
assert(l->size >= sizeof(struct objc_method));
return (struct objc_method*)(((char*)l->methods) + (i * l->size));
Expand Down
2 changes: 1 addition & 1 deletion properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct objc_property_list
* `objc_property` structs, which have fields appended that this version of the
* runtime does not know about.
*/
static struct objc_property *property_at_index(struct objc_property_list *l, int i)
static inline struct objc_property *property_at_index(struct objc_property_list *l, int i)
{
assert(l->size >= sizeof(struct objc_property));
return (struct objc_property*)(((char*)l->properties) + (i * l->size));
Expand Down
1 change: 0 additions & 1 deletion protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ void protocol_addProperty(Protocol *aProtocol,
}
struct objc_property_list *list = *listPtr;
int index = list->count-1;
const char *iVarName = NULL;
struct objc_property p = propertyFromAttrs(attributes, attributeCount, name);
assert(list->size == sizeof(p));
memcpy(&(list->properties[index]), &p, sizeof(p));
Expand Down
2 changes: 1 addition & 1 deletion protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct objc_protocol_method_description_list
* array of some future version of these structs, which have fields appended
* that this version of the runtime does not know about.
*/
static struct objc_protocol_method_description *
static inline struct objc_protocol_method_description *
protocol_method_at_index(struct objc_protocol_method_description_list *l, int i)
{
assert(l->size >= sizeof(struct objc_protocol_method_description));
Expand Down
1 change: 0 additions & 1 deletion runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@ void *object_getIndexedIvars(id obj)
size_t size = classForObject(obj)->instance_size;
if ((0 == size) && class_isMetaClass(classForObject(obj)))
{
Class cls = (Class)obj;
size = sizeof(struct objc_class);
}
return ((char*)obj) + size;
Expand Down

0 comments on commit 369c84d

Please sign in to comment.