gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Using smsd to send multiline sms


From: Pawel Kot
Subject: Re: [PATCH] Using smsd to send multiline sms
Date: Fri, 18 Jul 2008 17:33:58 +0200

Hi,

On Fri, Jul 18, 2008 at 16:42, Jan Derfinak <address@hidden> wrote:
> On Fri, 18 Jul 2008, Pawel Kot wrote:
>
>> IMHO memsets are not needed.
>> I'd also use construction (it's not needed if fgets() in case of
>> failure sets NULL as the string -- I cannot see this guaranteed in the
>> manpage):
>> if (!fgets(...)) {
>>     sms.something[0] = '\0';
>> }
>> slen = ....
>
> Are you sure that fgets changes address of destination string to NULL?

The code above assumes it doesn't.

> It returns NULL, but do not change destination string.

And I expect such behaviour in the code above.

> The idea of my construction is that memset initialize memory of the string
> with 0.

My point is that it is too much (especially data.text is quite large).
You just need to have NULL terminated string. There are two cases:
 - fgets() returns NULL: we NULL terminate it as above
 - fgets() returns not NULL: fgets() will NULL terminate the string.

pkot
-- 
Pawel Kot




reply via email to

[Prev in Thread] Current Thread [Next in Thread]