Title
#core
x

xzvno

06/21/2021, 1:39 AM
Hi, I have noticed that in
getChange
(osquery/core/watcher.cpp),
change
is uninitialized if
tryTo
throws an exception. And
change.footprint
is assigned to
state.initial_footprint
. Does it matter?
s

seph

06/21/2021, 2:07 PM
are you seeing this manifesting as an error, or in reading the code? I would generally say that matters… I’m not a c++, but it looks like
change
is declared and it’s various members worked with. Are you referring to
change.footprint
specifically?
2:12 PM
Oh, you said
tryTo
. Is that a method that can raise? I think it’s not supposed to raise. and instead return an error that
takeOr
works with
x

xzvno

06/22/2021, 12:25 AM
Oh, I'm sorry. It's not
tryTo
. It may be
at
or
takeOr
. Anyway, I mean if something is thrown, do we need to initialize
change
in the catch block?
12:26 AM
Or actually we don't need the catch block?
s

seph

06/23/2021, 1:05 PM
I'm not enough of a c++ person to be sure here. There is a try/catch block. And
change
is declared outside it. So if the members of that stuct are intialized as 0 when declared it seems fine. If they're undef it'd be bad. But I can't tell which is which.
x

xzvno

06/24/2021, 12:22 AM
Thanks for the reply. I'll open a blueprint issue about this.
s

seph

06/24/2021, 12:23 AM
It’s not blueprint. You’re asking a c++ question.
12:23 AM
Have you encountered an error, or is this all from first principles?
x

xzvno

06/24/2021, 12:45 AM
From first principles. I'd like to initialize
change
when it is declared (or in the catch block). Should I ask it here or open an issue?
s

seph

06/24/2021, 2:56 AM
Well, I’m the only one that answered here. So I suspect you’re not going to get a better response 😞
2:56 AM
opening an issue will likely get a more clear reply.
2:56 AM
My suspicion is that it’s fine as written
3:00 AM
I think if you were going to initialize them outside the try, it should happen at declare time. (before the try) may as well zero everything then
x

xzvno

06/24/2021, 3:27 AM
That is what I want (to initialize when declared). Thanks anyway. I'll try opening an issue to get more replies.
s

seph

06/24/2021, 4:10 AM
If it’s easy, you could also just PR it. I think it’s like a 4 line diff.
x

xzvno

06/24/2021, 7:15 AM
I've submitted a PR, just a 2 line diff.