Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation
From: SF Markus Elfring
Date: Thu Jan 19 2017 - 04:57:59 EST
>> +++ b/arch/um/drivers/port_kern.c
>> @@ -87,11 +87,8 @@ static int port_accept(struct port_list *port)
>> }
>>
>> conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
>> - if (conn == NULL) {
>> - printk(KERN_ERR "port_accept : failed to allocate "
>> - "connection\n");
>> + if (!conn)
>> goto out_close;
>> - }
>> *conn = ((struct connection)
>> { .list = LIST_HEAD_INIT(conn->list),
>> .fd = fd,
>
> I don't see how this eliminates a possible error.
The suggested change affects three coding style issues at this place.
* Repetition of an out-of-memory message
See also:
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
* Unwanted splitting of a message string
* Usage of a specific preprocessor symbol
> !x is something you use with something that is conceptually a Boolean.
Pointers can be also treated in this way, can't they?
Regards,
Markus