>They are, in fact, somewhat of a self-inflicted code review. Just writing
them make the code better in that you have to think very carefully about it
all.
True, though I would argue that at present, a little too much though is
required to get things working not uncommonly and sometimes then process is
just maddening. Also, maintaining code that someone else who wasn’t
interested in spending too much time thinking about this wrote is really,
really awful - unreadable AND not annotated correctly/usefully AND you
likely won’t know that unless you read through said unreadable code.
I’ve barely sort of kind of gotten this (hide annotations) to work in
SlickEdit through brute force by creating a copy of each of the 42 or so
different files that define annotations (prefast, SECURE_CRT, deprecated
functions, et. c.) and then creating a compiler tag set from that. It still
doesn’t work correctly, I think because it is in general
very difficult to convince slickedit that some of these constructs aren’t
functions. This I think is the same problem that affects Doxygen (which
came up in a thread a few weeks ago) and most any other source tool that
I’ve tried, since they can’t use the compiler to sort this stuff out.
‘scanf:’
MSDN:
int scanf(const char *format [, argument]… );
int _scanf_l(const char *format, locale_t locale [,argument]…);
int wscanf(const wchar_t *format [,argument]…);
int _wscanf_l(const wchar_t *format,locale_t locale [,argument]… );
$ grep -E ‘scanf’ stdio.h
Check_return _CRT_INSECURE_DEPRECATE(fscanf_s) _CRTIMP int __cdecl
fscanf(Inout FILE * _File, In_z Scanf_format_string const char *
_Format, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_fscanf_s_l) _CRTIMP int __cdecl
_fscanf_l(Inout FILE * _File, In_z Scanf_format_string const char *
_Form
at, In_opt _locale_t _Locale, …);
Check_return_opt _CRTIMP int __cdecl fscanf_s(Inout FILE * _File, In_z
Scanf_s_format_string const char * _Format, …);
Check_return_opt _CRTIMP int __cdecl _fscanf_s_l(Inout FILE * _File,
In_z Scanf_s_format_string const char * _Format, In_opt _locale_t
_Locale, .
…);
Check_return _CRT_INSECURE_DEPRECATE(scanf_s) _CRTIMP int __cdecl
scanf(In_z Scanf_format_string const char * _Format, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_scanf_s_l) _CRTIMP int __cdecl
_scanf_l(In_z Scanf_format_string const char * _Format, In_opt
_locale_t _
Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl scanf_s(In_z
Scanf_s_format_string const char * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl _scanf_s_l(In_z
Scanf_s_format_string const char * _Format, In_opt _locale_t _Locale,
…);
Check_return _CRT_INSECURE_DEPRECATE(sscanf_s) _CRTIMP int __cdecl
sscanf(In_z const char * _Src, In_z Scanf_format_string const char *
_Format, …
.);
Check_return_opt _CRT_INSECURE_DEPRECATE(_sscanf_s_l) _CRTIMP int __cdecl
_sscanf_l(In_z const char * _Src, In_z Scanf_format_string const char
* _
Format, In_opt _locale_t _Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl sscanf_s(In_z const
char * _Src, In_z Scanf_s_format_string const char * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl _sscanf_s_l(In_z const
char * _Src, In_z Scanf_s_format_string const char * _Format, In_opt
_loc
ale_t _Locale, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_snscanf_s) _CRTIMP int __cdecl
_snscanf(In_bytecount(_MaxCount) Pre_z const char * _Src, In size_t
_MaxCo
unt, In_z Scanf_format_string const char * _Format, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_snscanf_s_l) _CRTIMP int __cdecl
_snscanf_l(In_bytecount(_MaxCount) Pre_z const char * _Src, In size_t
_M
axCount, In_z Scanf_format_string const char * _Format, In_opt
_locale_t _Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl
_snscanf_s(In_bytecount(_MaxCount) Pre_z const char * _Src, In size_t
_MaxCount, In_z Scanf_s_f
ormat_string const char * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl
_snscanf_s_l(In_bytecount(_MaxCount) Pre_z const char * _Src, In
size_t _MaxCount, In_z _Scanf_s
format_string const char * _Format, In_opt _locale_t _Locale, …);
Check_return _CRT_INSECURE_DEPRECATE(fwscanf_s) _CRTIMP int __cdecl
fwscanf(Inout FILE * _File, In_z Scanf_format_string const wchar_t *
_Format, .
…);
Check_return_opt _CRT_INSECURE_DEPRECATE(_fwscanf_s_l) _CRTIMP int __cdecl
_fwscanf_l(Inout FILE * _File, In_z Scanf_format_string const wchar_t
*
_Format, In_opt _locale_t _Locale, …);
Check_return_opt _CRTIMP int __cdecl fwscanf_s(Inout FILE * _File,
In_z Scanf_s_format_string const wchar_t * _Format, …);
Check_return_opt _CRTIMP int __cdecl _fwscanf_s_l(Inout FILE * _File,
In_z Scanf_s_format_string const wchar_t * _Format, In_opt _locale_t
_Local
e, …);
Check_return _CRT_INSECURE_DEPRECATE(swscanf_s) _CRTIMP int __cdecl
swscanf(In_z const wchar_t * _Src, In_z Scanf_format_string const
wchar_t * _Fo
rmat, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_swscanf_s_l) _CRTIMP int __cdecl
_swscanf_l(In_z const wchar_t * _Src, In_z Scanf_format_string const
wch
ar_t * _Format, In_opt _locale_t _Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl swscanf_s(In_z const
wchar_t *_Src, In_z Scanf_s_format_string const wchar_t * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl _swscanf_s_l(In_z const
wchar_t * _Src, In_z Scanf_s_format_string const wchar_t * _Format,
In_op
t _locale_t _Locale, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_snwscanf_s) _CRTIMP int __cdecl
_snwscanf(In_count(_MaxCount) Pre_z const wchar_t * _Src, In size_t
_MaxC
ount, In_z Scanf_format_string const wchar_t * _Format, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_snwscanf_s_l) _CRTIMP int
__cdecl _snwscanf_l(In_count(_MaxCount) Pre_z const wchar_t * _Src, In
size_t _
MaxCount, In_z Scanf_format_string const wchar_t * _Format, In_opt
_locale_t _Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl
_snwscanf_s(In_count(_MaxCount) Pre_z const wchar_t * _Src, In size_t
_MaxCount, In_z Scanf_s_f
ormat_string const wchar_t * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl
_snwscanf_s_l(In_count(_MaxCount) Pre_z const wchar_t * _Src, In
size_t _MaxCount, In_z _Scanf_s
format_string const wchar_t * _Format, In_opt _locale_t _Locale, …);
Check_return _CRT_INSECURE_DEPRECATE(wscanf_s) _CRTIMP int __cdecl
wscanf(In_z Scanf_format_string const wchar_t * _Format, …);
Check_return_opt _CRT_INSECURE_DEPRECATE(_wscanf_s_l) _CRTIMP int __cdecl
_wscanf_l(In_z Scanf_format_string const wchar_t * _Format, In_opt
_local
e_t _Locale, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl wscanf_s(In_z
Scanf_s_format_string const wchar_t * _Format, …);
Check_return_opt _CRTIMP_ALTERNATIVE int __cdecl _wscanf_s_l(In_z
Scanf_s_format_string const wchar_t * _Format, In_opt _locale_t _Locale,
…);
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Sunday, December 12, 2010 8:35 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] PREfast annotations - IRQL, resources
They’re annoying to provide (after all, it’s a bit like writing your code
twice) and they clutter the code with ugly goop that is essentially
unreadable. OTOH, I agree that they could definitely contribute to code
quality.
They are, in fact, somewhat of a self-inflicted code review. Just writing
them make the code better in that you have to think very carefully about it
all. I would be very jazzed by a simple extension to the Visual Studio
syntax handling that basically had an View option to “hide annotations” /
“show annotations”. Straight ‘text’ based source-code files have become
rather overloaded [aka, sewer] trying to hold and convey the information
needed by authors, maintainers, reviewers, repositories, analysis tools, and
compilers to create, maintain, validate, manage and translate the ‘source’.
That camel’s back is under a lot of stress.
I sooo wish some of these checks transformed into run-time validations.
You mean akin to CLR annotations generating whole swaths of code (or hooks
into code, etc.)? That would be very powerful especially if it was
extensible to allow *me* to model *my* problem’s semantic verification at
the level of *my* abstraction and not just the OS’s idea of what is
interesting. But that would take the explicit cooperation of the Compiler
Dudes. Line that request up just behind guaranteed predictable C++
emission behavior (oh sh_t, now I have done it) and set expectations
accordingly.
Cheers,
Dave Cattley
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer