Hi, I have noticed that in `getChange` (osquery/co...
# core
x
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
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?
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
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?
Or actually we don't need the catch block?
s
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
Thanks for the reply. I'll open a blueprint issue about this.
s
It’s not blueprint. You’re asking a c++ question.
Have you encountered an error, or is this all from first principles?
x
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
Well, I’m the only one that answered here. So I suspect you’re not going to get a better response 😞
opening an issue will likely get a more clear reply.
My suspicion is that it’s fine as written
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
That is what I want (to initialize when declared). Thanks anyway. I'll try opening an issue to get more replies.
s
If it’s easy, you could also just PR it. I think it’s like a 4 line diff.
x
I've submitted a PR, just a 2 line diff.