[dev] test

2020-06-16 Thread Salvatore Cuzzilla



---
:wq,
Salvatore.



[dev] Re: [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread messw1thdbest
Sorry, I messed up the formatting

22d21
<   #include 
48c47
<   return bprintf("%d", (temp.value - 27315) / 1E6);
---
>   return bprintf("%d", (temp.value - 27315) / 100);


Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐
On Tuesday, June 16, 2020 5:33 PM, messw1thdbest  
wrote:

> Hi Suckless
>
> I think there is a problem with the temperature module,
> that is, on OpenBSD it only prints one digit,
> which by the way doesn't even change (stuck at 5).
>
> By making a small change, it now works properly.
> (I also removed stdio.h which looks unnecessary)
>
> 22d21
> < #include 
>
> 48c47
> < return bprintf("%d", (temp.value - 27315) / 1E6);
>
> --
>
> >   return bprintf("%d", (temp.value - 27315) / 100);
> >
>
> Thank's for your work!





[dev] [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread messw1thdbest
Hi Suckless

I think there is a problem with the temperature module,
that is, on OpenBSD it only prints one digit,
which by the way doesn't even change (stuck at 5).

By making a small change, it now works properly.
(I also removed stdio.h which looks unnecessary)

22d21
<   #include 
48c47
<   return bprintf("%d", (temp.value - 27315) / 1E6);
---
>   return bprintf("%d", (temp.value - 27315) / 100);

Thank's for your work!



Re: [dev] Re: [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread Laslo Hunhold
On Tue, 16 Jun 2020 20:53:34 +0200
Mattias Andrée  wrote:

Dear Mattias,

> I'm assuming temp.value i an `int`, as %d is used. The problem was
> probably that `1E6` is actually a `double` rather than an `int`,
> as the whole expression is promoted to `double`, because `bprintf` is
> (I assume) variadic, and the compiler does not know to change the
> cast the expression back to `int` because only the type of the first
> argument is specified in its declaration.

ah yes, of course! Thanks for pointing that out. It's never a good idea
to work with floats when you end up casting to int in a step inbetween
or after. Let's go with the FreeBSD-approach seen below that code.

With best regards

Laslo



Re: [dev] [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread Joerg Jung



> On 16. Jun 2020, at 22:30, Joerg Jung  wrote:
> 
> 
>> On 16. Jun 2020, at 20:53, Mattias Andrée  wrote:
>> 
>> I'm assuming temp.value i an `int`, as %d is used. The problem was
>> probably that `1E6` is actually a `double` rather than an `int`,
>> as the whole expression is promoted to `double`, because `bprintf` is
>> (I assume) variadic, and the compiler does not know to change the
>> cast the expression back to `int` because only the type of the first
>> argument is specified in its declaration.
> 
> Yes, you are likely right and with the %d "rounding” one even seems to
> loose the precision.
> That’s why %.1f for example would probably a better choice here

...or one could just use the same “calculation” as for FreeBSD a few lines 
below.

> , as there is a subtle difference between 94.1 and 94.9 degree one may
> want to know.
> 
>> On Tue, 16 Jun 2020 20:42:08 +0200
>> Laslo Hunhold  wrote:
>> 
>>> On Tue, 16 Jun 2020 17:55:03 +
>>> messw1thdbest  wrote:
>>> 
>>> Dear messw1thdbest,
>>> 
 <   return bprintf("%d", (temp.value - 27315) / 1E6);
 ---  
> return bprintf("%d", (temp.value - 27315)/100);
>>> 
>>> I'm really intrigued by that; thanks for sending in this patch! What is
>>> the origin of this problem? Does this have something to do with
>>> guaranteed constant-sizes in Posix?
>>> 
>>> With best regards
>>> 
>>> Laslo Hunhold
>>> 
>> 
>> 
> 




Re: [dev] [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread Joerg Jung


> On 16. Jun 2020, at 20:53, Mattias Andrée  wrote:
> 
> I'm assuming temp.value i an `int`, as %d is used. The problem was
> probably that `1E6` is actually a `double` rather than an `int`,
> as the whole expression is promoted to `double`, because `bprintf` is
> (I assume) variadic, and the compiler does not know to change the
> cast the expression back to `int` because only the type of the first
> argument is specified in its declaration.

Yes, you are likely right and with the %d "rounding” one even seems to
loose the precision.
That’s why %.1f for example would probably a better choice here, as 
there is a subtle difference between 94.1 and 94.9 degree one may
want to know.

> On Tue, 16 Jun 2020 20:42:08 +0200
> Laslo Hunhold  wrote:
> 
>> On Tue, 16 Jun 2020 17:55:03 +
>> messw1thdbest  wrote:
>> 
>> Dear messw1thdbest,
>> 
>>> <   return bprintf("%d", (temp.value - 27315) / 1E6);
>>> ---  
  return bprintf("%d", (temp.value - 27315)/100);
>> 
>> I'm really intrigued by that; thanks for sending in this patch! What is
>> the origin of this problem? Does this have something to do with
>> guaranteed constant-sizes in Posix?
>> 
>> With best regards
>> 
>> Laslo Hunhold
>> 
> 
> 




Re: [dev] Re: [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread Mattias Andrée
I'm assuming temp.value i an `int`, as %d is used. The problem was
probably that `1E6` is actually a `double` rather than an `int`,
as the whole expression is promoted to `double`, because `bprintf` is
(I assume) variadic, and the compiler does not know to change the
cast the expression back to `int` because only the type of the first
argument is specified in its declaration.


Regards,
Mattias Andrée


On Tue, 16 Jun 2020 20:42:08 +0200
Laslo Hunhold  wrote:

> On Tue, 16 Jun 2020 17:55:03 +
> messw1thdbest  wrote:
> 
> Dear messw1thdbest,
> 
> > <   return bprintf("%d", (temp.value - 27315) / 1E6);
> > ---  
> > >   return bprintf("%d", (temp.value - 27315)/100);
> 
> I'm really intrigued by that; thanks for sending in this patch! What is
> the origin of this problem? Does this have something to do with
> guaranteed constant-sizes in Posix?
> 
> With best regards
> 
> Laslo Hunhold
> 




Re: [dev] Re: [slstatus] temperature module acts wierd on OpenBSD

2020-06-16 Thread Laslo Hunhold
On Tue, 16 Jun 2020 17:55:03 +
messw1thdbest  wrote:

Dear messw1thdbest,

> <   return bprintf("%d", (temp.value - 27315) / 1E6);
> ---
> >   return bprintf("%d", (temp.value - 27315)/100);  

I'm really intrigued by that; thanks for sending in this patch! What is
the origin of this problem? Does this have something to do with
guaranteed constant-sizes in Posix?

With best regards

Laslo Hunhold