CURLcode
Before this patch, the result code was a mixture of `int` and `CURLcode`. Also adjust casts and fix a couple of minor issues found along the way. Cherry-picked from #13489 Closes #13600
Follow-up to 721941aadf Ref: #13257 Closes #13262
721941aadf