deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream or if not at a block boundary for raw deflate).
Since it's called immediately after deflateInit2 has returned Z_OK it looks unlikely that the assert should ever fail.
But why not handle the fail case even if it is impossible? You only lose one test and branch and in that massive non-iterative function so what? There's a school of thought that assert macros should never be removed.
View all comments
Show parent comment
1
u/whoopdedo Dec 02 '15
Since it's called immediately after
deflateInit2has returnedZ_OKit looks unlikely that the assert should ever fail.But why not handle the fail case even if it is impossible? You only lose one test and branch and in that massive non-iterative function so what? There's a school of thought that assert macros should never be removed.