make PREHASH variables char const* const (fixes VWR-24487: llurlentry_stub.cpp:196: error: deprecated conversion from string constant to 'char*')
Review Request #100 - Created Jan. 18, 2011 and submitted
Boroondas Gupte | Reviewers | ||
viewer | |||
VWR-24487 | seth.productengine | ||
None | viewer-development |
For the reason for this change, see https://jira.secondlife.com/browse/VWR-24487 and https://jira.secondlife.com/browse/VWR-24522 What I did: In indra/llmessage/message_prehash.(h|cpp), I turned everything into constant pointers to constants by search/replace. Then I tried to compile and added const qualifiers in dependent code as needed to stop the compiler complaining. Note that comments in indra/llmessage/message_prehash.(h|cpp) say these files have been generated from the message template. Because this generation might not have been a one-off thing, I changed the generating code, too, so it won't override this change here when the generation happens the next time. However, that part of the code is not called by Viewer, although the relevant function — dump_prehash_files() — ends up in the Viewer binary. That function probably gets called by the simulator, when one runs the latter with -prehash. (See https://bitbucket.org/lindenlab/viewer-development/src/fc7e5dcf3059/indra/llmessage/message.cpp#cl-2532 )
Compiled (standalone, 64bit Linux) with and without LL_TESTS. Started the viewer, logged in, walked and flew around a bit. Everything seems to work. Locally set _PREHASH_AgentData and _PREHASH_AgentID to (char const*)0x1 in indra/llui/tests/llurlentry_stub.cpp and indra/newview/tests/llremoteparcelrequest_test.cpp to verify they actually are never dereferenced, even when not NULL, so that using NULL pointers instead of place holder data won't change what code paths gets tested. Both tests binaries executed without crashes and all the contained tests passed. Locally invoked start_messaging_system() with b_dump_prehash_file == true instead of FALSE, to see what would be generated after my change to dump_prehash_files(). The message_prehash.(h|cpp) generated by that had the correct type qualifiers and formatting, but some lines were removed or added compared to the modified files from the source tree. That probably means that the files aren't fully synchronized with the message template file in the source tree. Because the "added" constants are spread all over the file, while the "removed" ones were at the end, I'd wager that message_prehash.(h|cpp) in the viewer source tree are actually more up-to-date than the message template file in the source tree.
I love it! Thanks, this was stopped me from compiling the tests (since some commit not long ago I guess, because I could before). Just one remark. In one test _PREHASH_AgentID is set to "AgentID" (no doubt a place holder), while in the other you set it to 0 (now needed because it's a const). Perhaps a more symmetric approach is better? I'd opt for setting the other also to a random string, like "Grumpity Productengine", or "Aleric Inglewood" now I think about it. Other options are "All Your Base Are Belong To Us" and "Hi mom!". Got be SURE they aren't used though -- don't want any new 'Grumpity' embarrashments :p
Posted (Jan. 20, 2011, 3:54 a.m.)
> Just one remark. In one test _PREHASH_AgentID is set to "AgentID" > (no doubt a place holder), while in the other you set it to 0 > (now needed because it's a const). Perhaps a more symmetric approach > is better?
-
indra/llui/tests/llurlentry_stub.cpp (Diff revision 1) -
This test already contained these placeholder strings, so I just left it at that, only adapting the types.
-
indra/newview/tests/llremoteparcelrequest_test.cpp (Diff revision 1) -
In this test here, however, I think the pointers actually ended up undefined in the original code, so setting them to NULL was the closest I possibility could think off. As building succeeded with this, I concluded that these pointers are passed around but never dereferenced during the test.[*] I feel setting nullpointers nicely signals that fact, though it should probably be augmented by a // never used during this test or // never dereferenced in this test comment to make that intent clear.
I agree though, that we should try to handle this similarly in both tests, if possible. So I tried setting the pointers in indra/llui/tests/llurlentry_stub.cpp to NULL, too, which works nicely. However, I then realized that the tested code might have nullpointer guards around dereferencing code, so that if we pass nullpointers we are actually testing another scenario than when passing pointers to actual data and that this might be the reason why no null-pointer exceptions occur during the tests. Of course, we could now examine the tested code to see whether this is the case. However, it would be a bad idea to adapt the test code based on that examination, as the tested code might be changed later without this question being re-evaluated and the test rewritten accordingly. Is there another pointer value besides NULL (thus not usually tested for) that still fails reliably when tried to dereference? ---- [*] Remember that tests are executed when building and are hopefully completely deterministic, so that any potential null-pointer-exception would have shown up.
Review request changed
Updated (Jan. 20, 2011, 2:57 p.m.)
-
- added Diff r2
-
Compiled (standalone, 64bit Linux) with and without LL_TESTS. Started the viewer, logged in, walked and flew around a bit. Everything seems to work.
Compiled (standalone, 64bit Linux) with and without LL_TESTS. Started the viewer, logged in, walked and flew around a bit. Everything seems to work. Locally set _PREHASH_AgentData and _PREHASH_AgentID to (char const*)0x1 in indra/llui/tests/llurlentry_stub.cpp and indra/newview/tests/llremoteparcelrequest_test.cpp to verify they actually are never dereferenced, even when not NULL, so that using NULL pointers instead of place holder data won't change what code paths gets tested. Both tests binaries executed without crashes and all the contained tests passed.
-
- added seth.productengine
Successfully tested with (char const*)0x1, so using NULL pointers, now. Adding Seth as reviewer, as he introduced the place holder data that would now get replaced by NULL.
Not a fan of widespread cleanup changes as I said in a previous review, but if this is getting rid of compilation errors on some machines, I'm all for it.
Posted (Jan. 22, 2011, 3:20 a.m.)
As already mentioned in the review request description, comments in message_prehash.h and message_prehash.cpp claim that these files have been generated:
-
indra/llmessage/message_prehash.h (Diff revision 2) -
-
indra/llmessage/message_prehash.cpp (Diff revision 2) -
Do we have to expect them to be re-generated again in the future? If so, the code for generating them should be changed alongside the change I propose here, so that future generations (pun intended) won't inadvertently override and revert the change. At first, I thought the code for generating them was not part of the source tree, but now I think I have located it in indra/llmessage/message.cpp. (I would have expected it to be a script, not a compiled program.) I will investigate this further and augment the review request with a change to the generating code, too, if applicable.
Review request changed
Updated (Jan. 22, 2011, 7:40 a.m.)
-
- added Diff r3
-
Compiled (standalone, 64bit Linux) with and without LL_TESTS. Started the viewer, logged in, walked and flew around a bit. Everything seems to work. Locally set _PREHASH_AgentData and _PREHASH_AgentID to (char const*)0x1 in indra/llui/tests/llurlentry_stub.cpp and indra/newview/tests/llremoteparcelrequest_test.cpp to verify they actually are never dereferenced, even when not NULL, so that using NULL pointers instead of place holder data won't change what code paths gets tested. Both tests binaries executed without crashes and all the contained tests passed.
Compiled (standalone, 64bit Linux) with and without LL_TESTS. Started the viewer, logged in, walked and flew around a bit. Everything seems to work. Locally set _PREHASH_AgentData and _PREHASH_AgentID to (char const*)0x1 in indra/llui/tests/llurlentry_stub.cpp and indra/newview/tests/llremoteparcelrequest_test.cpp to verify they actually are never dereferenced, even when not NULL, so that using NULL pointers instead of place holder data won't change what code paths gets tested. Both tests binaries executed without crashes and all the contained tests passed. Locally invoked start_messaging_system() with b_dump_prehash_file == true instead of FALSE, to see what would be generated after my change to dump_prehash_files(). The message_prehash.(h|cpp) generated by that had the correct type qualifiers and formatting, but some lines were removed or added compared to the modified files from the source tree. That probably means that the files aren't fully synchronized with the message template file in the source tree. Because the "added" constants are spread all over the file, while the "removed" ones were at the end, I'd wager that message_prehash.(h|cpp) in the viewer source tree are actually more up-to-date than the message template file in the source tree.
-
For the reason for this change, see https://jira.secondlife.com/browse/VWR-24487 and https://jira.secondlife.com/browse/VWR-24522 What I did: In indra/llmessage/message_prehash.(h|cpp), I turned everything into constant pointers to constants by search/replace. Then I tried to compile and added const qualifiers in dependent code as needed to stop the compiler complaining. Note that comments in indra/llmessage/message_prehash.(h|cpp) say these files have been generated from the message template. If this generation wasn't a one-off thing, the generating code must be changed, too, so it won't override this change here when the generation happens the next time.
For the reason for this change, see https://jira.secondlife.com/browse/VWR-24487 and https://jira.secondlife.com/browse/VWR-24522 What I did: In indra/llmessage/message_prehash.(h|cpp), I turned everything into constant pointers to constants by search/replace. Then I tried to compile and added const qualifiers in dependent code as needed to stop the compiler complaining. Note that comments in indra/llmessage/message_prehash.(h|cpp) say these files have been generated from the message template. Because this generation might not have been a one-off thing, I changed the generating code, too, so it won't override this change here when the generation happens the next time. However, that part of the code is not called by Viewer, although the relevant function — dump_prehash_files() — ends up in the Viewer binary. That function probably gets called by the simulator, when one runs the latter with -prehash. (See https://bitbucket.org/lindenlab/viewer-development/src/fc7e5dcf3059/indra/llmessage/message.cpp#cl-2532 )
Found and changed the generating code for message_prehash.(h|cpp), too.
Latest diff looks good. Great that you found the generator for this code!
Posted (Jan. 24, 2011, 6:42 a.m.)
If the file is generated, what is it doing checked into the source tree at all? This sounds to me like an invitation to future errors. Is there some reason why we should not just delete the checked in version and have it generated every time it's needed?
Posted (Jan. 24, 2011, 9:43 a.m.)
Given that Boroondas reports that the message.cpp in the viewer source tree does not produce the same generated file as what we have checked in, and Q's comment that this shared code, should we remove the message.cpp from this tree and just use the generated file? Would that break tests? It seems axiomatic to me that there should only be one source for this - if the authoritative one is the one in the simulator sources, that's fine, but there should only be one. I don't like the idea of making changes (however good they are, and I agree that the new declarations are cleaner) that are not in sync with the server side.
Posted (Jan. 26, 2011, 9:05 a.m.)
I'm ok with changing declarations of some pointers to _PREHASH_ strings and setting them to NULL as they are not de-referenced and not really used in tests now. But I'm not sure about changes to code generating all the other _PREHASH_ declarations because it's not yet clear how they should be re-generated.
Posted (Feb. 3, 2011, 6:35 p.m.)
Review request changed
Updated (March 7, 2011, 3:51 p.m.)
- changed from make PREHASH variables char const* const to make PREHASH variables char const* const (fixes VWR-24487: llurlentry_stub.cpp:196: error: deprecated conversion from string constant to 'char*')
(just mentioning the jira issue in the summary)
Other reviews