From: Dan Carpenter <dan.carpenter@oracle.com>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
ohering@suse.com, Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH 2/4] Drivers: hv: Support the newly introduced KVP messages in the driver
Date: Sun, 11 Mar 2012 13:42:31 +0300 [thread overview]
Message-ID: <20120311104230.GC3337@mwanda> (raw)
In-Reply-To: <1331422331-4381-2-git-send-email-kys@microsoft.com>
[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]
On Sat, Mar 10, 2012 at 03:32:09PM -0800, K. Y. Srinivasan wrote:
> + switch (message->kvp_hdr.operation) {
> + case KVP_OP_SET:
> + switch (in_msg->body.kvp_set.data.value_type) {
> + case REG_SZ:
> + /*
> + * The value is a string - utf16 encoding.
> + */
> + message->body.kvp_set.data.value_size =
> + utf16s_to_utf8s(
> + (wchar_t *)
> + in_msg->body.kvp_set.data.value,
> + in_msg->body.kvp_set.data.value_size,
> + UTF16_LITTLE_ENDIAN,
> + message->body.kvp_set.data.value,
> + HV_KVP_EXCHANGE_MAX_VALUE_SIZE) + 1;
> + break;
> +
This block of unreadable text is so nasty.
You could return directly if the msg = kmalloc() fails and pull
everything in one indent level. It's normally more readable to
handle errors as soon as possible anyway.
Probably that's not enough to make a difference and we'd need to
introduce a new function.
Btw I don't know if utf16s_to_utf8s() counts the NUL char or not.
It feels like maybe we could end up with ->value_size equal to
HV_KVP_EXCHANGE_MAX_VALUE_SIZE + 1.
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-03-11 10:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-10 23:31 [PATCH 0000/0004] drivers: hv K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 1/4] Drivers: hv: Add new message types to enhance KVP K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 2/4] Drivers: hv: Support the newly introduced KVP messages in the driver K. Y. Srinivasan
2012-03-11 10:42 ` Dan Carpenter [this message]
2012-03-11 16:01 ` Alan Stern
2012-03-11 16:56 ` KY Srinivasan
2012-03-11 18:49 ` Dan Carpenter
2012-03-11 20:53 ` KY Srinivasan
2012-03-12 5:22 ` Dan Carpenter
2012-03-12 12:36 ` KY Srinivasan
2012-03-12 13:03 ` Dan Carpenter
2012-03-15 23:36 ` KY Srinivasan
2012-03-16 5:38 ` Dan Carpenter
2012-03-16 5:43 ` KY Srinivasan
2012-03-10 23:32 ` [PATCH 3/4] Tools: hv: Fully support the new KVP verbs in the user level daemon K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 4/4] Tools: hv: Support enumeration from all the pools K. Y. Srinivasan
2012-03-13 21:50 ` [PATCH 0000/0004] drivers: hv Greg KH
2012-03-15 23:26 ` KY Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120311104230.GC3337@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ohering@suse.com \
--cc=stern@rowland.harvard.edu \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox