DaanDeMeyer / reproc

A cross-platform (C99/C++11) process library
MIT License
552 stars 65 forks source link

Variable referenced twice #30

Closed Milerius closed 4 years ago

Milerius commented 4 years ago

https://github.com/DaanDeMeyer/reproc/blob/00b8616ec935752985cbc53ad0cef42f9f698358/reproc%2B%2B/include/reproc%2B%2B/detail/array.hpp#L27

Hey, any reason why the variable is assigned twice time here ?

DaanDeMeyer commented 4 years ago

Nope, that's a bug. Thanks for pointing it out! I'll push a fix immediately.

Milerius commented 4 years ago

no problem, you maybe interested to use https://www.viva64.com/en/pvs-studio/

It's free for open source project, since I'm using your library I got the report from your library too @DaanDeMeyer

DaanDeMeyer commented 4 years ago

That's pretty nifty, I'll look into setting up some more static analyzers for reproc including PVS. Of course, you're welcome to keep reporting these things if PVS finds any more.

(I hope the latest changes didn't impact you too heavily, I did some breaking changes but they should be mostly contained to the C library)

Milerius commented 4 years ago

TBH with you I'm stick to a specific commits since a moment @DaanDeMeyer I will upgrade when a new release tag will be ready.

Milerius commented 4 years ago
Capture d’écran 2019-12-26 à 23 26 55

There is this one too but seem's to be a false positive @DaanDeMeyer

DaanDeMeyer commented 4 years ago

Ahh, I thought you got the PVS warning because you were following the master branch but the warning was simply from an old version.

The second one is indeed a false positive, although it shouldn't trigger anymore in newer commits as I've completely revised error handling in the C implementation.

Milerius commented 4 years ago

Ah yeah that's why, ok I will upgrade once the new tag is release so.

DaanDeMeyer commented 4 years ago

I'll try and get the new version out the door ASAP so you can use a stable release again.

Milerius commented 4 years ago

very nice. Recently I liked a lot the approach of the API process from the nim programming langage:

https://github.com/nim-lang/Nim/blob/version-1-0/lib/pure/osproc.nim#L66

I liked a lot the API that's look like:

            mm2Instance = startProcess(command=toolsPath & "/mm2", args=[$$mm2_cfg], env = nil, options={poParentStreams}, workingDir=toolsPath)

May be you will find the API/code interesting for inspiring ^^'