I would like to know what happens if in my dispatch routine I write
UNREFERENCED_PARAMETER ( DeviceObject);
And then later use
devExt_c = DeviceObject->DeviceExtension;
In the same dispatch routine …
Should it bug chech ?, if so what will be the violation?.
Regards,
Anurag
This macro is just to surpress compiler warnings, it has no effect on the
actual code. But, the great thing about macros is that you have the source
for them. Check out the definition of the macro and its accompanying comment
in NTDEF.H and all should be clear.
Regards,
-scott
–
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Anurag Sarin” wrote in message
news:xxxxx@ntdev…
I would like to know what happens if in my dispatch routine I write
UNREFERENCED_PARAMETER ( DeviceObject);
And then later use
devExt_c = DeviceObject->DeviceExtension;
In the same dispatch routine …
Should it bug chech ?, if so what will be the violation?.
Regards,
Anurag
UNREFERENCED_PARAMETER(x) translates to something like:
x = x;
It simply references the parameter. Check the macro definition and see for
yourself.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Anurag Sarin
Sent: Friday, January 14, 2005 9:18 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Query
I would like to know what happens if in my dispatch routine I write
UNREFERENCED_PARAMETER ( DeviceObject);
And then later use
devExt_c = DeviceObject->DeviceExtension;
In the same dispatch routine …
Should it bug chech ?, if so what will be the violation?.
Regards,
Anurag
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
__________ NOD32 1.970 (20050113) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com
Here’s what ntdef.h has to say about it:
//
// Macros used to eliminate compiler warning generated when formal
// parameters or local variables are not declared.
//
// Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
// referenced but will be once the module is completely developed.
//
// Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
// referenced but will be once the module is completely developed.
//
// Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
//
// DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
// eventually be made into a null macro to help determine whether there
// is unfinished work.
//
Reading the definitions of the macro, it doesn’t actually do anything other
than “reference the variable”.
This, of course, means that you COULD put “UNREFERENCED_VARIABLE” around
any variable you like without any problem or concern, except that it’s
misleading to the reader…
Look at the macro definitions in ntdef.h if you wish to see how this is
done.
–
Mats
xxxxx@lists.osr.com wrote on 01/14/2005 02:18:25 PM:
I would like to know what happens if in my dispatch routine I write
UNREFERENCED_PARAMETER ( DeviceObject);
And then later use
devExt_c = DeviceObject->DeviceExtension;
In the same dispatch routine …
Should it bug chech ?, if so what will be the violation?.
Regards,
Anurag
Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
ForwardSourceID:NT0000AE1A
Yes. C++ users can just omit the actual parameter name like
func(int i, int)
{
}
- to say that the second parameter is unused by the function body.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Jamey Kirby”
To: “Windows System Software Devs Interest List”
Sent: Friday, January 14, 2005 5:25 PM
Subject: RE: [ntdev] Query
> UNREFERENCED_PARAMETER(x) translates to something like:
>
> x = x;
>
> It simply references the parameter. Check the macro definition and see for
> yourself.
>
> Jamey
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Anurag Sarin
> Sent: Friday, January 14, 2005 9:18 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Query
>
> I would like to know what happens if in my dispatch routine I write
>
> UNREFERENCED_PARAMETER ( DeviceObject);
>
> And then later use
>
> devExt_c = DeviceObject->DeviceExtension;
>
> In the same dispatch routine …
>
> Should it bug chech ?, if so what will be the violation?.
>
> Regards,
> Anurag
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> NOD32 1.970 (20050113) Information
>
> This message was checked by NOD32 antivirus system.
> http://www.nod32.com
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
From a code review standpoint, if you use UNREFERENCED_PARAMETER, regardless
of what the compiler does or doesn’t do, you must not reference the
parameter (duh!, wouldn’t pass my audit unless I was sleeping.)
The C++ compiler mode enforces this rule as it actually supports compile
time unreferenced parameter syntax. Not of course that one should do
anything as horrid as use C++ in the kernel, but one might consider using
the C++ mode of the compiler
=====================
Mark Roddy
Windows .NET/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mats PETERSSON
Sent: Friday, January 14, 2005 9:34 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Query
Here’s what ntdef.h has to say about it:
//
// Macros used to eliminate compiler warning generated when
formal // parameters or local variables are not declared.
//
// Use DBG_UNREFERENCED_PARAMETER() when a parameter is not
yet // referenced but will be once the module is completely developed.
//
// Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local
variable is not yet // referenced but will be once the module
is completely developed.
//
// Use UNREFERENCED_PARAMETER() if a parameter will never be
referenced.
//
// DBG_UNREFERENCED_PARAMETER and
DBG_UNREFERENCED_LOCAL_VARIABLE will // eventually be made
into a null macro to help determine whether there // is
unfinished work.
//
Reading the definitions of the macro, it doesn’t actually do
anything other than “reference the variable”.
This, of course, means that you COULD put
“UNREFERENCED_VARIABLE” around any variable you like without
any problem or concern, except that it’s misleading to the reader…
Look at the macro definitions in ntdef.h if you wish to see
how this is done.
–
Mats
xxxxx@lists.osr.com wrote on 01/14/2005 02:18:25 PM:
> I would like to know what happens if in my dispatch routine I write
>
> UNREFERENCED_PARAMETER ( DeviceObject);
>
> And then later use
>
> devExt_c = DeviceObject->DeviceExtension;
>
> In the same dispatch routine …
>
> Should it bug chech ?, if so what will be the violation?.
>
> Regards,
> Anurag
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.
> osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst
tag argument:
‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
> ForwardSourceID:NT0000AE1A
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com
> The C++ compiler mode enforces this rule as it actually supports compile
time unreferenced parameter syntax. Not of course that one should do
It does it badly, mixing the interface with implementation.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
> The C++ compiler mode enforces this rule as it actually
supports compile time unreferenced parameter syntax. Not of
course that one should do anything as horrid as use C++ in
the kernel, but one might consider using the C++ mode of the
compiler
To add what Mark said:
In order to cleanly pass “/wall” compilation which is the very first item in
my acceptance checklist,
I have to use UNREFERENCED_PARAMETER in the driver even it is written in C.
By the way, it’s impossible to pass “/wall” without adding pragmas to make
DDK headers compiled.
Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com
If /wall is the equivalent of /W4, then that issue has been worked on
quite extensively. W4 clean DDK headers (at least ntddk.h, wdm.h)
should be in the WDK/LDK (or whatever we call it now :))/
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Calvin Guan
Sent: Friday, January 14, 2005 9:17 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Query
The C++ compiler mode enforces this rule as it actually
supports compile time unreferenced parameter syntax. Not of
course that one should do anything as horrid as use C++ in
the kernel, but one might consider using the C++ mode of the
compiler
To add what Mark said:
In order to cleanly pass “/wall” compilation which is the very first
item in
my acceptance checklist,
I have to use UNREFERENCED_PARAMETER in the driver even it is written in
C.
By the way, it’s impossible to pass “/wall” without adding pragmas to
make
DDK headers compiled.
Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com