static void *my_malloc(void *ref, size_t n) { register void *mem; #ifndef DIAG_MEM_ERRORS mem = os_alloc_memory(n, GFP_KERNEL); #else { uint32_t rand; /* are we feeling lucky ? */ os_get_random_bytes(&rand, sizeof(rand)); if ((rand % DIAG_MEM_CONST) == 0) { mem = 0; } else { mem = os_alloc_memory(n, GFP_ATOMIC); } } #endif /* DIAG_MEM_ERRORS */ #ifdef DIAG_MEM sprintf(Diag_msg, "API kmalloc: %p for %d\n", mem, n); LOG_KDIAG(Diag_msg); #endif ref = 0; /* unused param warning */ return mem; }
static sah_Head_Desc *my_alloc_head_desc(void *ref) { register sah_Head_Desc *ptr; #ifndef DIAG_MEM_ERRORS ptr = sah_Alloc_Head_Descriptor(); #else { uint32_t rand; /* are we feeling lucky ? */ os_get_random_bytes(&rand, sizeof(rand)); if ((rand % DIAG_MEM_CONST) == 0) { ptr = 0; } else { ptr = sah_Alloc_Head_Descriptor(); } } #endif ref = 0; return ptr; }
static void __setup_cluster(test_cluster_t *c) { os_get_random_bytes(&c->uuid, sizeof(exa_uuid_t)); c->tms[0] = NULL; c->tms[1] = NULL; }