[Nut-upsdev] Why only the first of a series of calls to a function in my driver executing?

Kelly Byrd kbyrd at memcpy.com
Tue Oct 22 22:56:05 BST 2024


Ahh, C memory management and str functions are fun! I like them soooo much,
I chose `memcpy` as my vanity domain!


On Tue, Oct 22, 2024 at 2:14 PM William R. Elliot <bill at wreassoc.com> wrote:

> At 02:41 AM 10/22/2024, Jim Klimov wrote:
>
> Hello, always nice to hear about new drivers :)
>
> OTOH, check for any variables you might have been re-using, so their
> earlier state impacts later runs - whether buffers allocated statically (or
> by caller without rewinding the pointer and maybe nulling the contents), or
> position counters, etc. Similarly, be sure to pre-initialize anything of
> value and not start out with random bits from the stack.
>
> Also if it is about a series of calls - are there some (loop?) conditions
> between the calls that might just preclude them from being called in the
> first place?
>
> Old-school tracing with debug printouts is good in very many cases;
> otherwise it can really help to stage a run in an IDE with a debugger.
> Cross-platform wise, I've had consistently good experience with NetBeans
> (installing the C/C++ plugin from the NB 8.2 archive after every NB upgrade
> is a PITA though); VSCode also worked (at least when I drilled into NUT for
> Windows builds with MSYS2) - hints on both are in NUT docs.
>
> Hope this helps,
> Jim Klimov
>
>
>
> On Tue, Oct 22, 2024 at 5:01 AM William R. Elliot <bill at wreassoc.com>
> wrote:
>
> Hello all,
>
> In my new driver I have a function that searches for the position of
> a known substring in a delimited string. I am trying to populate a
> series of integer variables with the position value of various
> substrings. The first call to the function performs correctly but the
> remaining calls in the code series are not being executed (there are
> six more calls after the first successful one). Any ideas why only
> the first call is being done?
>
> Similarly, I have another function that takes a position variable and
> pulls the data in the nth position from a delimited string. There is
> also a series of these called in a row and only the first is being called.
>
> Any ideas on what to look for would be appreciated.
>
> Thanks,
>
> Bill
>
>
>
> --
> This email has been checked for viruses by AVG antivirus software.
> www.avg.com
>
> _______________________________________________
> Nut-upsdev mailing list
> Nut-upsdev at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev
>
>
> Thanks for the response Jim.
>
> The problem had to do with my mis-understanding of the strtok library
> function internals. Making a local copy of the source string in my
> function(s) solved the problem as the source buffer was getting whacked by
> strtok.
>
> Moving on.
>
> Bill
>
>
>
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
> Virus-free.www.avg.com
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
> <#m_3051551105968768373_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> _______________________________________________
> Nut-upsdev mailing list
> Nut-upsdev at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsdev/attachments/20241022/71375601/attachment.htm>


More information about the Nut-upsdev mailing list