From: Ivajlo Dimitrov <ivo.g.dimitrov.75@gmail.com>
To: Joe Perches <joe@perches.com>,
Ivaylo DImitrov <ivo.g.dimitrov.75@gmail.com>
Cc: omar.ramirez@copitl.com, gregkh@linuxfoundation.org,
pali.rohar@gmail.com, pavel@ucw.cz, linux-kernel@vger.kernel.org,
devel@driverdev.osuosl.org,
Ivaylo Dimitrov <freemangordon@abv.bg>
Subject: Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
Date: Mon, 02 Dec 2013 01:26:40 +0200 [thread overview]
Message-ID: <529BC5B0.8010202@gmail.com> (raw)
In-Reply-To: <1385924770.2664.14.camel@joe-AO722>
On 01.12.2013 21:06, Joe Perches wrote:
> On Sun, 2013-12-01 at 19:07 +0200, Ivaylo DImitrov wrote:
>> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>>
>> Custom uuid helper function is needed only in rmgr/dbdcd.c and doesn't
>> need to be exported. It can also be made way simpler by using sscanf.
> []
>> diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
> []
>> @@ -74,6 +74,40 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
>> enum nldr_phase phase);
>>
>> /*
>> + * ======== dcd_uuid_from_string ========
>> + * Purpose:
>> + * Converts an ANSI string to a dsp_uuid.
>> + * Parameters:
>> + * sz_uuid: Pointer to a string that represents a dsp_uuid object.
>> + * uuid_obj: Pointer to a dsp_uuid object.
>> + * Returns:
>> + * Requires:
>> + * uuid_obj & sz_uuid are non-NULL values.
>> + * Ensures:
>> + * Details:
>> + * We assume the string representation of a UUID has the following format:
>> + * "12345678_1234_1234_1234_123456789abc".
>> + */
>> +static void dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
>> +{
>> + char c;
>> + u64 t;
>> +
>> + /*
>> + * sscanf implementation cannot deal with hh format modifier
>> + * if the converted value doesn't fit in u32. So, convert the
>> + * last six bytes to u64 and memcpy what is needed
>> + */
>> + sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
>> + &uuid_obj->data1, &c, &uuid_obj->data2, &c,
>> + &uuid_obj->data3, &c, &uuid_obj->data4,
>> + &uuid_obj->data5, &c, &t);
>> +
>> + t = cpu_to_be64(t);
>> + memcpy(&uuid_obj->data6[0], ((char*)&t) + 2, 6);
>> +}
> It'd probably be better to return true or false on
> successful conversion, use a temporary struct dsp_uuid,
> check the sscanf return is 10 and only copy to uuid_obj
> on success.
>
> Something like:
>
> static bool dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
> {
> char c;
> u64 t;
> struct dsp_uuid tmp;
>
> /*
> * sscanf implementation cannot deal with hh format modifier
> * if the converted value doesn't fit in u32. So, convert the
> * last six bytes to u64 and memcpy what is needed
> */
> if (sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
> &tmp.data1, &c, &tmp.data2, &c,
> &tmp.data3, &c, &tmp.data4,
> &tmp.data5, &c, &t) != 10)
> return false;
>
> t = cpu_to_be64(t);
> memcpy(&tmp.data6[0], ((char*)&t) + 2, 6);
> *uuid_obj = tmp;
>
> return true;
> }
>
>
If there is to be a return value from that function, it is better to be
int (-EINVAL/0), IMO. And I am not sure that makes much of a sense, as
(afaik) uuids are read from baseimage.dof and codec nodes, if those are
broken I suspect wrong uuids will be our least problem.
next prev parent reply other threads:[~2013-12-01 23:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-01 17:07 [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper Ivaylo DImitrov
2013-12-01 19:06 ` Joe Perches
2013-12-01 23:26 ` Ivajlo Dimitrov [this message]
2013-12-06 6:05 ` Ivajlo Dimitrov
2013-12-06 7:32 ` Dan Carpenter
2013-12-06 7:41 ` Ivajlo Dimitrov
2013-12-06 15:10 ` gregkh
2013-12-07 8:41 ` Ivajlo Dimitrov
2013-12-08 7:18 ` gregkh
2013-12-08 12:32 ` Pavel Machek
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
2013-12-09 14:40 ` Pavel Machek
2013-12-09 18:34 ` Joe Perches
2013-12-10 22:03 ` [PATCH v3] " Ivaylo DImitrov
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=529BC5B0.8010202@gmail.com \
--to=ivo.g.dimitrov.75@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=freemangordon@abv.bg \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omar.ramirez@copitl.com \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
/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