-
Notifications
You must be signed in to change notification settings - Fork 324
Topic silence warnings #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topic silence warnings #364
Conversation
italic does not work in verbatim paragraphs, remove it: sed -i -e 's/^\( *.*\)I</\1</g' xdotool.pod Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
.. when allocating space for tokens while parsing. The array allocation was checked already, also check that allocating memory for the content works out fine. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
I was getting 'Unknown command: <garbage-on-stack>' for a sequence of commands that containted no newline: echo -n "several commands and args here" | xdotool - fgets null-terminates the buffer, but we were tokenizing past the end of the read line in the while-loop since we skipped the _final_ zero byte. There was another bug when tokenizing the commandline arguments when one token spans more than one buffer, the token was seen as two arguments, cut in half mid-word where the previous buffer ended and the new buffer started. E.g.: printf "mousemove%-4083s--polar -- 0 0" " " complained that "Unknown command: olar". Another incarnation of the same bug could be observed if you fed a token into script_main that was longer than the buffer size: It was split on the buffer boundary, making several tokens out of the single token given by the user. E.g.: perl -le 'print(("X"x 9000))' > input-9000 or python3 -c 'print("X" * 9000)' > input-9000 and looking at the script argv when cat input-9000 | xdotool - Or printf "mousemove%4107s" "--polar -- 0 0 sleep 0.1" > /tmp/i (cat /tmp/i;echo " sleep 4";echo mousemove --polar -- 30 30) | ./xdotool - Fix this by correctly handling tokens that cross buffers. Diagnose allocation failures while at it. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
window_arg was strdup()ed but not freed, fix that. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
SUS specifies that free(NULL) is perfectly valid (a noop). Remove superfluous guards. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
This is a private helper-function of window_get_arg() and not used anywhere else. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
and remove now redundant declarations. A single declaration avoids the risk of diverging scattered declarations. Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
These live in xdo_cmd.h so are redundant in xdotool.c Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
1) warning: no previous prototype for ‘xdo_get_window_classname’ 2) warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness for classhint.res_class Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: There several commits that make what seem to be unrelated changes. Combine this with the PR subject "Topic silence warnings" with almost no information in the PR description, and it feels like not enough detail.
In the future, I'd love to see more details about the intent of the change (silence what warnings? When do the warnings show up? How do these changes improve things? etc).
That said, I do like the code cleanup, thank you!
I will also test the script changes before merging.
I wrote a test case for the script buffer changes 👍 |
Where "long" means longer than the script buffer size which, at this time, is 4096 bytes. Verified this test case fails prior to #364 being merged and succeeds after.
Added a test case: a3f4994 |
These were meant to be 3 distinct patchsets. If you checkout https://github.com/aldot/xdotool.git and look at the history via
The 4 "silence warnings" patches are: and should each contain a rational for the change.
You're welcome. |
Another good test would be to span an argument to the next buffer: is the expected behaviour. I think that would be a good testcase; If you don't like sleep the any other command will of course do to demonstrate the issue. |
* xdotool.1: Fix rendering of example commands italic does not work in verbatim paragraphs, remove it: sed -i -e 's/^\( *.*\)I</\1</g' xdotool.pod Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * Error out on allocation failure .. when allocating space for tokens while parsing. The array allocation was checked already, also check that allocating memory for the content works out fine. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * Fix tokenizing a single-line command chain I was getting 'Unknown command: <garbage-on-stack>' for a sequence of commands that containted no newline: echo -n "several commands and args here" | xdotool - fgets null-terminates the buffer, but we were tokenizing past the end of the read line in the while-loop since we skipped the _final_ zero byte. There was another bug when tokenizing the commandline arguments when one token spans more than one buffer, the token was seen as two arguments, cut in half mid-word where the previous buffer ended and the new buffer started. E.g.: printf "mousemove%-4083s--polar -- 0 0" " " complained that "Unknown command: olar". Another incarnation of the same bug could be observed if you fed a token into script_main that was longer than the buffer size: It was split on the buffer boundary, making several tokens out of the single token given by the user. E.g.: perl -le 'print(("X"x 9000))' > input-9000 or python3 -c 'print("X" * 9000)' > input-9000 and looking at the script argv when cat input-9000 | xdotool - Or printf "mousemove%4107s" "--polar -- 0 0 sleep 0.1" > /tmp/i (cat /tmp/i;echo " sleep 4";echo mousemove --polar -- 30 30) | ./xdotool - Fix this by correctly handling tokens that cross buffers. Diagnose allocation failures while at it. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * fix memory leak in mousemove, mousedown window_arg was strdup()ed but not freed, fix that. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * Remove superfluous guards around free(NULL) SUS specifies that free(NULL) is perfectly valid (a noop). Remove superfluous guards. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * window_is_valid(): make static This is a private helper-function of window_get_arg() and not used anywhere else. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * context_execute(): Move prototype to xdo_cmd.h and remove now redundant declarations. A single declaration avoids the risk of diverging scattered declarations. Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * xdotool: Remove redundant declarations These live in xdo_cmd.h so are redundant in xdotool.c Signed-off-by: Bernhard Reutner-Fischer <[email protected]> * getwindowclassname: silence warning 1) warning: no previous prototype for ‘xdo_get_window_classname’ 2) warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness for classhint.res_class Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
Where "long" means longer than the script buffer size which, at this time, is 4096 bytes. Verified this test case fails prior to jordansissel#364 being merged and succeeds after.
Silence some warnings.
Thanks!