Microsoft Security Annotation Language (aka SAL)

declspec SAL と attribute SAL の違い

So why a new SAL syntax? I have good news and really good news. First, the good news: other than a simple macro syntax change, there is not a lot new to learn in part because the macros are similar (not identical, however) and the major difference, the low-level primitives, are abstracted away.
なぜ新しい SAL 文法なのか?これについてはいいニュースと本当にすばらしいニュースがある。まずはいいニュースから。マクロ文法はほとんど変わらず、新たに学ぶことはほとんどない。マクロは似ていて(もちろん一致はしない)、大きな違いは下層のプリミティブにあるんだけれど抽象化して隠してある。

Now for the really good news. Attribute SAL is much more rigorous than declspec SAL, which means analysis tools can find more bugs with lower false positives (‘noise’). For example, declspec SAL is often silent in the face of an incorrect annotation.
そして本当にすばらしいニュースについて。 attribute SAL は declspec SAL より厳格になっている。つまり解析ツールはより多くのバグを見つけるようになる上、誤検出(ノイズ)は少なくなる。たとえば declspec SAL は不正確なアノテーションについてよくほっかむりをしていたものだ。

The introduction of attribute SAL does not mean declspec SAL is dead, but it does mean that we will not be investing any more resources into declspec SAL, all our energy improving SAL and our analysis tools use of SAL will be in attribute SAL. At a pragmatic level, this means:
attribute SAL の出現は declspec SAL の終わりではない。今後 declspec SAL には投資せず、 SAL を磨き上げることに全精力を傾け、解析ツールでは attribute SAL が利用されるようになる、とそういうことだ。実務的側面からすると:

  • If you have already invested in using declspec SAL you should migrate over to attribute SAL as time allows, and use new attribute SAL for new functions. Both syntaxes can co-exist.

すでに declspec SAL に投資していたのであれば attribute SAL に乗り換えに時間を使ってほしい。そして新しい実装では attribute SAL を使ってほしい。両文法は混在可能だ。

  • If you have never used SAL, you should use attribute SAL. As far as you’re concerned, declspec SAL never existed.

まだ SAL を導入していないなら attribute SAL を使うこと。目に見える範囲ではもう declspec SAL は存在しない。

One noticeable difference in macro names is the use of declspec SAL’s “count” and attribute SAL’s “cap” and “count.” The former is a buffer size in elements or bytes, but the latter two are the buffer’s writing capacity and the size of the buffer for reading, respectively.
マクロ名について一番の違いは declspec の “count” と attribute での “cap” および “count” だろう。 declspec ではバッファの要素数あるいはバイト数を意味していたが attribute では、書き込み上限に対して “cap” を、読み取り可能サイズについて “count” を使うようになっている。

An important addition to attribute SAL is _Printf_format_string_ which can be used to find many printf-related format-matching ills.
attribute SAL について付け加えておくべき大事なことは _Printf_format_string_ で、これは printf に関連する書式のミスマッチに関して多くのバグを見つける役に立つ。

http://blogs.msdn.com/sdl/archive/2009/06/11/a-declspec-sal-to-attribute-sal-rosetta-stone.aspx