vanderlin / ofxBox2d

Openframework wrapper for box2d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove warning in ofxBox2dBaseShape::setData()

totalgee opened this issue · comments

Next time you're tidying up little things, could you please add a return NULL; at the end of ofxBox2dBaseShape::setData()? Otherwise, you get compiler warnings -- and in the off case that data is not NULL and the shape is not a body, who knows what random data will be returned? (Maybe that case can never happen, but at least you can get rid of the compiler warning.)

void* ofxBox2dBaseShape::setData(void*data) {

    if(data == NULL) {
        ofLog(OF_LOG_NOTICE, "ofxBox2dBaseShape:: - data is NULL -");
        return NULL;
    }

    if(isBody()) {
        ofLog(OF_LOG_NOTICE, "ofxBox2dBaseShape:: - custom data set %p", data);
        body->SetUserData(data);
        return data;
    }
    else {
        ofLog(OF_LOG_NOTICE, "ofxBox2dBaseShape:: - must have a valid body -");
    }
    return NULL;    // <----- add this!
}

Thanks.