Re: Fix workaround skipping leading 'x' for ModelNumStr

Daniele Forsi <[email protected]> Thu, 27 Feb 2014 12:46:56 +0100
Newsgroups gmane.comp.ipod.gtkpod
Message-ID <CAN_we7M2=+w6rwMAb9AFuj0uSATCFjFJu8yYgz4eT7CQ_Wua4g@mail.gmail.com>
2014-02-27 8:21 GMT+01:00 Yasuhiro MATSUMOTO:

> Currently, some application (sorry i don't know) wrote SysInfo in below.
>   /iPod_Control/Device/SysInfo
> And it seems that gtkpod expect xY000 like string.
> But some times this leading 'x' doesn't set. Maybe it depend on
> libmodiledevice or another libraries?
> Below is a patch for getting ModelNumStr old workaround.
> Please check and include.
>
> - Yasuhiro Matsumoto
>
>
> diff --git a/src/itdb_device.c b/src/itdb_device.c
> index 80995de..4f10675 100644
> --- a/src/itdb_device.c
> +++ b/src/itdb_device.c
> @@ -2113,7 +2113,8 @@ get_ipod_info_from_model_number (const char
> *model_number)
>      g_return_val_if_fail (model_number != NULL, NULL);
>
>      model_table = get_model_table ();
> -    if(isalpha(model_number[0])) {
> +    /* Fix workarounds skipping leading 'x' */
> +    if(model_number[0] == 'x' && model_number[1] != '\0') {

why are you testing model_number[1]? the original code didn't test it

if you want the leading 'x' if present I would remove the comment and
just do that:
-    if(isalpha(model_number[0])) {
+    if (model_number[0] == 'x') {

for consistency, it's better to add a space between "if" and the
opening parens (there are only 2 lines in this file where "if" isn't
followed by a space and 76 where it is followed by a space)

-- 
Daniele Forsi

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk