* Warning in '__loc_network_tree_count()'
@ 2023-03-04 10:44 Gisle Vanem
2023-03-04 10:51 ` Michael Tremer
0 siblings, 1 reply; 4+ messages in thread
From: Gisle Vanem @ 2023-03-04 10:44 UTC (permalink / raw)
To: location
[-- Attachment #1: Type: text/plain, Size: 607 bytes --]
Hello list.
Compiling with 'clang-cl' on Windows-10, I saw this
important warning:
network.c(796,10): warning: variable 'counter' set but not used [-Wunused-but-set-variable]
size_t* counter = (size_t*)data;
^
So shouldn't the function be:
static int __loc_network_tree_count(struct loc_network* network, void* data) {
size_t* counter = (size_t*)data;
// Increase the counter for each network
(*counter)++;
return 0;
}
But I fail to see this ret-val is used for anything.
BTW, disasm now is correct:
inc qword ptr [rdx]
xor eax,eax
ret
--
--gv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Warning in '__loc_network_tree_count()'
2023-03-04 10:44 Warning in '__loc_network_tree_count()' Gisle Vanem
@ 2023-03-04 10:51 ` Michael Tremer
2023-03-04 11:00 ` Gisle Vanem
0 siblings, 1 reply; 4+ messages in thread
From: Michael Tremer @ 2023-03-04 10:51 UTC (permalink / raw)
To: location
[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]
Hello Gisle,
Thanks for your email.
> On 4 Mar 2023, at 10:44, Gisle Vanem <gvanem(a)online.no> wrote:
>
> Hello list.
>
> Compiling with 'clang-cl' on Windows-10, I saw this
> important warning:
> network.c(796,10): warning: variable 'counter' set but not used [-Wunused-but-set-variable]
> size_t* counter = (size_t*)data;
> ^
>
> So shouldn't the function be:
>
> static int __loc_network_tree_count(struct loc_network* network, void* data) {
> size_t* counter = (size_t*)data;
>
> // Increase the counter for each network
> (*counter)++;
> return 0;
Yes, you are incorrect. I am incrementing the pointer when I wanted to increment the value. Probably this is an artefact from rewriting the code a few times.
But indeed this has not been a problem since the function is not being called at all in the code, and it is not being exported.
So assuming that it is not very useful, I will drop loc_network_tree_count_networks and the callback function.
Thank you for helping to improve libloc. How does it run on Windows?
Best,
-Michael
> }
>
> But I fail to see this ret-val is used for anything.
>
> BTW, disasm now is correct:
> inc qword ptr [rdx]
> xor eax,eax
> ret
>
>
> --
> --gv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Warning in '__loc_network_tree_count()'
2023-03-04 10:51 ` Michael Tremer
@ 2023-03-04 11:00 ` Gisle Vanem
2023-03-04 11:03 ` Michael Tremer
0 siblings, 1 reply; 4+ messages in thread
From: Gisle Vanem @ 2023-03-04 11:00 UTC (permalink / raw)
To: location
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
Michael Tremer wrote:
>> So shouldn't the function be:
>>
>> static int __loc_network_tree_count(struct loc_network* network, void* data) {
>> size_t* counter = (size_t*)data;
>>
>> // Increase the counter for each network
>> (*counter)++;
>> return 0;
>
> Yes, you are incorrect. I am incrementing the pointer when I wanted to increment the value.
You mean "you are correct"?
> Thank you for helping to improve libloc. How does it run on Windows?
I doesn't run at all w/o much patching by myself. I've added
support for it and 'location.db' files in my project Wsock-trace:
https://github.com/gvanem/wsock-trace
The patched up 'libloc' version:
https://github.com/gvanem/wsock-trace/tree/master/src/Geo-IP/IPFire/src
--
--gv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Warning in '__loc_network_tree_count()'
2023-03-04 11:00 ` Gisle Vanem
@ 2023-03-04 11:03 ` Michael Tremer
0 siblings, 0 replies; 4+ messages in thread
From: Michael Tremer @ 2023-03-04 11:03 UTC (permalink / raw)
To: location
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
Hello,
> On 4 Mar 2023, at 11:00, Gisle Vanem <gvanem(a)online.no> wrote:
>
> Michael Tremer wrote:
>
>>> So shouldn't the function be:
>>>
>>> static int __loc_network_tree_count(struct loc_network* network, void* data) {
>>> size_t* counter = (size_t*)data;
>>>
>>> // Increase the counter for each network
>>> (*counter)++;
>>> return 0;
>> Yes, you are incorrect. I am incrementing the pointer when I wanted to increment the value.
>
> You mean "you are correct"?
>
>> Thank you for helping to improve libloc. How does it run on Windows?
> I doesn't run at all w/o much patching by myself. I've added
> support for it and 'location.db' files in my project Wsock-trace:
> https://github.com/gvanem/wsock-trace
>
> The patched up 'libloc' version:
> https://github.com/gvanem/wsock-trace/tree/master/src/Geo-IP/IPFire/src
Do you intend to upstream those changes at some point (if that is possible)?
>
> --
> --gv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-04 11:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-04 10:44 Warning in '__loc_network_tree_count()' Gisle Vanem
2023-03-04 10:51 ` Michael Tremer
2023-03-04 11:00 ` Gisle Vanem
2023-03-04 11:03 ` Michael Tremer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox