Skip to content

Commit 97d3380

Browse files
author
Mike Snitzer
committed
dm vdo memory-alloc: return VDO_SUCCESS on success
Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Matthew Sakai <[email protected]>
1 parent ee8f6ec commit 97d3380

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

drivers/md/dm-vdo/memory-alloc.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static inline bool use_kmalloc(size_t size)
194194
* @what: What is being allocated (for error logging)
195195
* @ptr: A pointer to hold the allocated memory
196196
*
197-
* Return: UDS_SUCCESS or an error code
197+
* Return: VDO_SUCCESS or an error code
198198
*/
199199
int vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr)
200200
{
@@ -216,12 +216,12 @@ int vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr)
216216
unsigned long start_time;
217217
void *p = NULL;
218218

219-
if (ptr == NULL)
220-
return UDS_INVALID_ARGUMENT;
219+
if (unlikely(ptr == NULL))
220+
return -EINVAL;
221221

222222
if (size == 0) {
223223
*((void **) ptr) = NULL;
224-
return UDS_SUCCESS;
224+
return VDO_SUCCESS;
225225
}
226226

227227
if (allocations_restricted)
@@ -245,7 +245,7 @@ int vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr)
245245
} else {
246246
struct vmalloc_block_info *block;
247247

248-
if (vdo_allocate(1, struct vmalloc_block_info, __func__, &block) == UDS_SUCCESS) {
248+
if (vdo_allocate(1, struct vmalloc_block_info, __func__, &block) == VDO_SUCCESS) {
249249
/*
250250
* It is possible for __vmalloc to fail to allocate memory because there
251251
* are no pages available. A short sleep may allow the page reclaimer
@@ -290,7 +290,7 @@ int vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr)
290290
}
291291

292292
*((void **) ptr) = p;
293-
return UDS_SUCCESS;
293+
return VDO_SUCCESS;
294294
}
295295

296296
/*
@@ -335,7 +335,7 @@ void vdo_free(void *ptr)
335335
* @what: What is being allocated (for error logging)
336336
* @new_ptr: A pointer to hold the reallocated pointer
337337
*
338-
* Return: UDS_SUCCESS or an error code
338+
* Return: VDO_SUCCESS or an error code
339339
*/
340340
int vdo_reallocate_memory(void *ptr, size_t old_size, size_t size, const char *what,
341341
void *new_ptr)
@@ -345,11 +345,11 @@ int vdo_reallocate_memory(void *ptr, size_t old_size, size_t size, const char *w
345345
if (size == 0) {
346346
vdo_free(ptr);
347347
*(void **) new_ptr = NULL;
348-
return UDS_SUCCESS;
348+
return VDO_SUCCESS;
349349
}
350350

351351
result = vdo_allocate(size, char, what, new_ptr);
352-
if (result != UDS_SUCCESS)
352+
if (result != VDO_SUCCESS)
353353
return result;
354354

355355
if (ptr != NULL) {
@@ -360,7 +360,7 @@ int vdo_reallocate_memory(void *ptr, size_t old_size, size_t size, const char *w
360360
vdo_free(ptr);
361361
}
362362

363-
return UDS_SUCCESS;
363+
return VDO_SUCCESS;
364364
}
365365

366366
int vdo_duplicate_string(const char *string, const char *what, char **new_string)
@@ -369,12 +369,12 @@ int vdo_duplicate_string(const char *string, const char *what, char **new_string
369369
u8 *dup;
370370

371371
result = vdo_allocate(strlen(string) + 1, u8, what, &dup);
372-
if (result != UDS_SUCCESS)
372+
if (result != VDO_SUCCESS)
373373
return result;
374374

375375
memcpy(dup, string, strlen(string) + 1);
376376
*new_string = dup;
377-
return UDS_SUCCESS;
377+
return VDO_SUCCESS;
378378
}
379379

380380
void vdo_memory_init(void)

drivers/md/dm-vdo/memory-alloc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int __must_check vdo_allocate_memory(size_t size, size_t align, const char *what
3535
* @what: What is being allocated (for error logging)
3636
* @ptr: A pointer to hold the allocated memory
3737
*
38-
* Return: UDS_SUCCESS or an error code
38+
* Return: VDO_SUCCESS or an error code
3939
*/
4040
static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra,
4141
size_t align, const char *what, void *ptr)
@@ -65,7 +65,7 @@ static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra,
6565
* @WHAT: What is being allocated (for error logging)
6666
* @PTR: A pointer to hold the allocated memory
6767
*
68-
* Return: UDS_SUCCESS or an error code
68+
* Return: VDO_SUCCESS or an error code
6969
*/
7070
#define vdo_allocate(COUNT, TYPE, WHAT, PTR) \
7171
__vdo_do_allocation(COUNT, sizeof(TYPE), 0, __alignof__(TYPE), WHAT, PTR)
@@ -81,7 +81,7 @@ static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra,
8181
* @WHAT: What is being allocated (for error logging)
8282
* @PTR: A pointer to hold the allocated memory
8383
*
84-
* Return: UDS_SUCCESS or an error code
84+
* Return: VDO_SUCCESS or an error code
8585
*/
8686
#define vdo_allocate_extended(TYPE1, COUNT, TYPE2, WHAT, PTR) \
8787
__extension__({ \
@@ -105,7 +105,7 @@ static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra,
105105
* @what: What is being allocated (for error logging)
106106
* @ptr: A pointer to hold the allocated memory
107107
*
108-
* Return: UDS_SUCCESS or an error code
108+
* Return: VDO_SUCCESS or an error code
109109
*/
110110
static inline int __must_check vdo_allocate_cache_aligned(size_t size, const char *what, void *ptr)
111111
{

0 commit comments

Comments
 (0)