Re: [Patch] cygcheck: Don't use keyeprint if GetLastError is irrelevant.
Op Sat, 30 Oct 2004 19:42:16 -0400 schreef Christopher Faylor in [EMAIL PROTECTED]: : On Sat, Oct 30, 2004 at 11:32:27PM +0200, Bas van Gompel wrote: : 2004-10-28 Bas van Gompel [EMAIL PROTECTED] : : * cygcheck.cc (get_dword): Fix errormessage. : (cygwin_info): Ditto. : (track_down): Ditto. : (check_keys): Ditto. : : Go ahead and check these in. Done, thanks. L8r, Buzz. -- ) | | ---/ ---/ Yes, this | This message consists of true | I do not -- | | // really is | and false bits entirely.| mail for ) | | //a 72 by 4 +---+ any1 but -- \--| /--- /--- .sigfile. | |perl -pe s.u(z)\1.as.| me. 4^re
Re: [Patch] cygcheck: Don't use keyeprint if GetLastError is irrelevant.
Op Fri, 29 Oct 2004 11:22:38 -0400 schreef Christopher Faylor in [EMAIL PROTECTED]: : On Fri, Oct 29, 2004 at 06:31:11AM +0200, Bas van Gompel wrote: : Following (trivial, once more, I hope) patch cleans up some of the : (IMO) inappropriate ``keyeprint'' usage in cygcheck. It (keyeprint) : should not be used when GetLastError does not apply, I think. Also the : format ending in ``failed'' can cause strange messages like ``NULL : pointer for file failed''. : : If malloc failed, it is not inconceivable that there is a system error. Ok. : Since the point of keyeprint is to print error messages, reverting to : using raw puts is a step backwards. If it is really known that there is : not a remote possibility that GetLastError will be useful, then an : option to keyeprint should be added. I thought so too, at first. I'll admit my solution wasn't pretty either. Maybe a new function sh/could be added to print messages on stderr, but without the ``failed'' suffix and the LastError output. (This could then be called from keyeprint as well.) : I'd rather regularize error output : throughout cygcheck (which may be a bigger job than your current assignment : status will allow) than sprinkle fputs's, and fprints's around the code. I hope a step-by-step approach will work... [...] : While doing this I caught a typo in get_dword. I'll start by trying to fix that one (and some more). (The ones in track_down don't look like they can ever really get triggered.) ChangeLog-entry: 2004-10-28 Bas van Gompel [EMAIL PROTECTED] * cygcheck.cc (get_dword): Fix errormessage. (cygwin_info): Ditto. (track_down): Ditto. (check_keys): Ditto. --- src/winsup/utils-keye-usage-p0/cygcheck.cc 27 Oct 2004 01:28:07 - 1.58 +++ src/winsup/utils-keye-usage-p0/cygcheck.cc 30 Oct 2004 03:16:07 - @@ -276,7 +276,7 @@ get_dword (HANDLE fh, int offset) if (SetFilePointer (fh, offset, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER GetLastError () != NO_ERROR) -keyeprint (get_word: SetFilePointer()); +keyeprint (get_dword: SetFilePointer()); if (!ReadFile (fh, rv, 4, (DWORD *) r, 0)) keyeprint (get_dword: Readfile()); @@ -359,7 +359,7 @@ cygwin_info (HANDLE h) buf_start = buf = (char *) calloc (1, size + 1); if (buf == NULL) { - keyeprint (cygwin_info: malloc()); + keyeprint (cygwin_info: calloc()); return; } @@ -537,13 +537,13 @@ track_down (char *file, char *suffix, in { if (file == NULL) { - keyeprint (track_down: malloc()); + keyeprint (track_down: NULL passed for file); return; } if (suffix == NULL) { - keyeprint (track_down: malloc()); + keyeprint (track_down: NULL passed for suffix); return; } @@ -1271,7 +1271,7 @@ check_keys () OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE || h == NULL) -return (keyeprint (check_key: Opening CONIN$)); +return (keyeprint (check_keys: Opening CONIN$)); DWORD mode; @@ -1281,7 +1281,7 @@ check_keys () { mode = ~ENABLE_PROCESSED_INPUT; if (!SetConsoleMode (h, mode)) - keyeprint (check_keys: GetConsoleMode()); + keyeprint (check_keys: SetConsoleMode()); } fputs (\nThis key check works only in a console window,, stderr); @@ -1300,7 +1300,7 @@ check_keys () { prev_in = in; if (!ReadConsoleInput (h, in, 1, mode)) - keyeprint (ReadConsoleInput); + keyeprint (check_keys: ReadConsoleInput()); if (!memcmp (in, prev_in, sizeof in)) continue; L8r, Buzz. -- ) | | ---/ ---/ Yes, this | This message consists of true | I do not -- | | // really is | and false bits entirely.| mail for ) | | //a 72 by 4 +---+ any1 but -- \--| /--- /--- .sigfile. | |perl -pe s.u(z)\1.as.| me. 4^re
Re: [Patch] cygcheck: Don't use keyeprint if GetLastError is irrelevant.
On Sat, Oct 30, 2004 at 11:32:27PM +0200, Bas van Gompel wrote: 2004-10-28 Bas van Gompel [EMAIL PROTECTED] * cygcheck.cc (get_dword): Fix errormessage. (cygwin_info): Ditto. (track_down): Ditto. (check_keys): Ditto. Go ahead and check these in. Thanks, cgf
Re: [Patch] cygcheck: Don't use keyeprint if GetLastError is irrelevant.
On Fri, Oct 29, 2004 at 06:31:11AM +0200, Bas van Gompel wrote: Following (trivial, once more, I hope) patch cleans up some of the (IMO) inappropriate ``keyeprint'' usage in cygcheck. It (keyeprint) should not be used when GetLastError does not apply, I think. Also the format ending in ``failed'' can cause strange messages like ``NULL pointer for file failed''. If malloc failed, it is not inconceivable that there is a system error. Since the point of keyeprint is to print error messages, reverting to using raw puts is a step backwards. If it is really known that there is not a remote possibility that GetLastError will be useful, then an option to keyeprint should be added. I'd rather regularize error output throughout cygcheck (which may be a bigger job than your current assignment status will allow) than sprinkle fputs's, and fprints's around the code. cgf While doing this I caught a typo in get_dword. ChangeLog-entry: 2004-10-28 Bas van Gompel [EMAIL PROTECTED] * cygcheck.cc (add_path): Don't use keyeprint when GetLastError is irrelevant. (find_on_path): Ditto. (rva_to_offset): Ditto. (cygwin_info): Ditto. (get_dword): Fix typo in errormessage. --- src/winsup/utils/cygcheck.cc 27 Oct 2004 01:28:07 - 1.58 +++ src/winsup/utils/cygcheck.cc 29 Oct 2004 03:34:15 - @@ -122,7 +122,7 @@ add_path (char *s, int maxlen) paths[num_paths] = (char *) malloc (maxlen + 1); if (paths[num_paths] == NULL) { - keyeprint (add_path: malloc()); + fputs (cygcheck: add_path: malloc() failed, stderr); return; } memcpy (paths[num_paths], s, maxlen); @@ -185,13 +185,14 @@ find_on_path (char *file, char *default_ if (!file) { - keyeprint (find_on_path: NULL pointer for file); + fputs (cygcheck: find_on_path: NULL pointer for file, stderr); return 0; } if (default_extension == NULL) { - keyeprint (find_on_path: NULL pointer for default_extension); + fputs (cygcheck: find_on_path: NULL pointer for default_extension, + stderr); return 0; } @@ -276,7 +277,7 @@ get_dword (HANDLE fh, int offset) if (SetFilePointer (fh, offset, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER GetLastError () != NO_ERROR) -keyeprint (get_word: SetFilePointer()); +keyeprint (get_dword: SetFilePointer()); if (!ReadFile (fh, rv, 4, (DWORD *) r, 0)) keyeprint (get_dword: Readfile()); @@ -300,7 +301,7 @@ rva_to_offset (int rva, char *sections, if (sections == NULL) { - keyeprint (rva_to_offset: NULL passed for sections); + fputs (cygcheck: rva_to_offset: NULL passed for sections, stderr); return 0; } @@ -359,7 +360,7 @@ cygwin_info (HANDLE h) buf_start = buf = (char *) calloc (1, size + 1); if (buf == NULL) { - keyeprint (cygwin_info: malloc()); + fputs (cygcheck: cygwin_info: calloc() failed, stderr); return; } L8r, Buzz. -- ) | | ---/ ---/ Yes, this | This message consists of true | I do not -- | | // really is | and false bits entirely.| mail for ) | | //a 72 by 4 +---+ any1 but -- \--| /--- /--- .sigfile. | |perl -pe s.u(z)\1.as.| me. 4^re
[Patch] cygcheck: Don't use keyeprint if GetLastError is irrelevant.
Hi, Following (trivial, once more, I hope) patch cleans up some of the (IMO) inappropriate ``keyeprint'' usage in cygcheck. It (keyeprint) should not be used when GetLastError does not apply, I think. Also the format ending in ``failed'' can cause strange messages like ``NULL pointer for file failed''. While doing this I caught a typo in get_dword. ChangeLog-entry: 2004-10-28 Bas van Gompel [EMAIL PROTECTED] * cygcheck.cc (add_path): Don't use keyeprint when GetLastError is irrelevant. (find_on_path): Ditto. (rva_to_offset): Ditto. (cygwin_info): Ditto. (get_dword): Fix typo in errormessage. --- src/winsup/utils/cygcheck.cc27 Oct 2004 01:28:07 - 1.58 +++ src/winsup/utils/cygcheck.cc29 Oct 2004 03:34:15 - @@ -122,7 +122,7 @@ add_path (char *s, int maxlen) paths[num_paths] = (char *) malloc (maxlen + 1); if (paths[num_paths] == NULL) { - keyeprint (add_path: malloc()); + fputs (cygcheck: add_path: malloc() failed, stderr); return; } memcpy (paths[num_paths], s, maxlen); @@ -185,13 +185,14 @@ find_on_path (char *file, char *default_ if (!file) { - keyeprint (find_on_path: NULL pointer for file); + fputs (cygcheck: find_on_path: NULL pointer for file, stderr); return 0; } if (default_extension == NULL) { - keyeprint (find_on_path: NULL pointer for default_extension); + fputs (cygcheck: find_on_path: NULL pointer for default_extension, + stderr); return 0; } @@ -276,7 +277,7 @@ get_dword (HANDLE fh, int offset) if (SetFilePointer (fh, offset, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER GetLastError () != NO_ERROR) -keyeprint (get_word: SetFilePointer()); +keyeprint (get_dword: SetFilePointer()); if (!ReadFile (fh, rv, 4, (DWORD *) r, 0)) keyeprint (get_dword: Readfile()); @@ -300,7 +301,7 @@ rva_to_offset (int rva, char *sections, if (sections == NULL) { - keyeprint (rva_to_offset: NULL passed for sections); + fputs (cygcheck: rva_to_offset: NULL passed for sections, stderr); return 0; } @@ -359,7 +360,7 @@ cygwin_info (HANDLE h) buf_start = buf = (char *) calloc (1, size + 1); if (buf == NULL) { - keyeprint (cygwin_info: malloc()); + fputs (cygcheck: cygwin_info: calloc() failed, stderr); return; } L8r, Buzz. -- ) | | ---/ ---/ Yes, this | This message consists of true | I do not -- | | // really is | and false bits entirely.| mail for ) | | //a 72 by 4 +---+ any1 but -- \--| /--- /--- .sigfile. | |perl -pe s.u(z)\1.as.| me. 4^re