static void ubus_lookup_cb(struct ubus_request *ureq, int type, struct blob_attr *msg)
{
struct ubus_lookup_request *req;
- struct ubus_object_data obj;
+ struct ubus_object_data obj = {};
struct blob_attr **attr;
req = container_of(ureq, struct ubus_lookup_request, req);
!attr[UBUS_ATTR_OBJTYPE])
return;
- memset(&obj, 0, sizeof(obj));
obj.id = blob_get_u32(attr[UBUS_ATTR_OBJID]);
obj.path = blob_data(attr[UBUS_ATTR_OBJPATH]);
obj.type_id = blob_get_u32(attr[UBUS_ATTR_OBJTYPE]);
const char *pattern)
{
struct ubus_object *obj = &ev->obj;
- struct blob_buf b2;
+ struct blob_buf b2 = {};
int ret;
if (!obj->id) {
}
/* use a second buffer, ubus_invoke() overwrites the primary one */
- memset(&b2, 0, sizeof(b2));
blob_buf_init(&b2, 0);
blobmsg_add_u32(&b2, "object", obj->id);
if (pattern)
}
/* setup the policy pointers */
- p = malloc(sizeof(struct blobmsg_policy) * plen);
+ p = calloc(plen, sizeof(struct blobmsg_policy));
if (!p)
return 1;
- memset(p, 0, sizeof(struct blobmsg_policy) * plen);
m->policy = p;
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
int midx = 0;
/* setup object pointers */
- obj = malloc(sizeof(struct ubus_lua_object));
+ obj = calloc(1, sizeof(struct ubus_lua_object));
if (!obj)
return NULL;
- memset(obj, 0, sizeof(struct ubus_lua_object));
obj->o.name = lua_tostring(L, -2);
/* setup method pointers */
- m = malloc(sizeof(struct ubus_method) * mlen);
- memset(m, 0, sizeof(struct ubus_method) * mlen);
+ m = calloc(mlen, sizeof(struct ubus_method));
obj->o.methods = m;
/* setup type pointers */
- obj->o.type = malloc(sizeof(struct ubus_object_type));
+ obj->o.type = calloc(1, sizeof(struct ubus_object_type));
if (!obj->o.type) {
free(obj);
return NULL;
}
- memset(obj->o.type, 0, sizeof(struct ubus_object_type));
obj->o.type->name = lua_tostring(L, -2);
obj->o.type->id = 0;
obj->o.type->methods = obj->o.methods;
{
struct ubus_lua_event* event = NULL;
- event = malloc(sizeof(struct ubus_lua_event));
+ event = calloc(1, sizeof(struct ubus_lua_event));
if (!event)
return NULL;
- memset(event, 0, sizeof(struct ubus_lua_event));
event->e.cb = ubus_event_handler;
/* update the he callback lookup table */
lua_error( L );
}
- sub = malloc( sizeof( struct ubus_lua_subscriber ) );
- memset( sub, 0, sizeof( struct ubus_lua_subscriber ) );
+ sub = calloc( 1, sizeof( struct ubus_lua_subscriber ) );
if( !sub ){
lua_pushstring( L, "Out of memory" );
lua_error( L );