Re: Fix workaround skipping leading 'x' for ModelNumStr

Yasuhiro MATSUMOTO <[email protected]> Fri, 28 Feb 2014 12:49:16 +0900
Newsgroups gmane.comp.ipod.gtkpod
Message-ID <CAJc+XFOT27UWGA7sH+ViAahH3ZZ3MV+sVbUmU_5KCtexgU1eUA@mail.gmail.com>
--===============6310364424679950590==
Content-Type: multipart/alternative; boundary=001a113aabac6a1bc704f36f527e

--001a113aabac6a1bc704f36f527e
Content-Type: text/plain; charset=UTF-8

Hi

I think that it's better to skip if model_name is just 'x'.



On Thu, Feb 27, 2014 at 8:46 PM, Daniele Forsi <[email protected]> wrote:

> 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
> _______________________________________________
> Gtkpod-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gtkpod-devel
>



-- 
- Yasuhiro Matsumoto

--001a113aabac6a1bc704f36f527e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi<div><br></div><div>I think that it&#39;s better to skip=
 if model_name is just &#39;x&#39;.</div><div><br></div></div><div class=3D=
"gmail_extra"><br><br><div class=3D"gmail_quote">On Thu, Feb 27, 2014 at 8:=
46 PM, Daniele Forsi <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]=
om" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">2014-02-27 8:21 GMT+01:00 Yasuhiro MATSUMOTO=
:<br>
<div class=3D""><br>
&gt; Currently, some application (sorry i don&#39;t know) wrote SysInfo in =
below.<br>
&gt; =C2=A0 /iPod_Control/Device/SysInfo<br>
&gt; And it seems that gtkpod expect xY000 like string.<br>
&gt; But some times this leading &#39;x&#39; doesn&#39;t set. Maybe it depe=
nd on<br>
&gt; libmodiledevice or another libraries?<br>
&gt; Below is a patch for getting ModelNumStr old workaround.<br>
&gt; Please check and include.<br>
&gt;<br>
&gt; - Yasuhiro Matsumoto<br>
&gt;<br>
&gt;<br>
&gt; diff --git a/src/itdb_device.c b/src/itdb_device.c<br>
&gt; index 80995de..4f10675 100644<br>
&gt; --- a/src/itdb_device.c<br>
&gt; +++ b/src/itdb_device.c<br>
&gt; @@ -2113,7 +2113,8 @@ get_ipod_info_from_model_number (const char<br>
&gt; *model_number)<br>
&gt; =C2=A0 =C2=A0 =C2=A0g_return_val_if_fail (model_number !=3D NULL, NULL=
);<br>
&gt;<br>
&gt; =C2=A0 =C2=A0 =C2=A0model_table =3D get_model_table ();<br>
&gt; - =C2=A0 =C2=A0if(isalpha(model_number[0])) {<br>
&gt; + =C2=A0 =C2=A0/* Fix workarounds skipping leading &#39;x&#39; */<br>
&gt; + =C2=A0 =C2=A0if(model_number[0] =3D=3D &#39;x&#39; &amp;&amp; model_=
number[1] !=3D &#39;\0&#39;) {<br>
<br>
</div>why are you testing model_number[1]? the original code didn&#39;t tes=
t it<br>
<br>
if you want the leading &#39;x&#39; if present I would remove the comment a=
nd<br>
just do that:<br>
- =C2=A0 =C2=A0if(isalpha(model_number[0])) {<br>
+ =C2=A0 =C2=A0if (model_number[0] =3D=3D &#39;x&#39;) {<br>
<br>
for consistency, it&#39;s better to add a space between &quot;if&quot; and =
the<br>
opening parens (there are only 2 lines in this file where &quot;if&quot; is=
n&#39;t<br>
followed by a space and 76 where it is followed by a space)<br>
<br>
--<br>
Daniele Forsi<br>
<br>
---------------------------------------------------------------------------=
---<br>
Flow-based real-time traffic analytics software. Cisco certified tool.<br>
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer<br>
Customize your own dashboards, set traffic alerts and generate reports.<br>
Network behavioral analysis &amp; security monitoring. All-in-one tool.<br>
<a href=3D"http://pubads.g.doubleclick.net/gampad/clk?id=3D126839071&amp;iu=
=3D/4140/ostg.clktrk" target=3D"_blank">http://pubads.g.doubleclick.net/gam=
pad/clk?id=3D126839071&amp;iu=3D/4140/ostg.clktrk</a><br>
_______________________________________________<br>
Gtkpod-devel mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]=
urceforge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/gtkpod-devel" targe=
t=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gtkpod-devel</a><=
br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>- Yasuhiro M=
atsumoto<br>
</div>

--001a113aabac6a1bc704f36f527e--


--===============6310364424679950590==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
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
--===============6310364424679950590==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Gtkpod-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

--===============6310364424679950590==--