if (path == NULL) {
          if (thermal_zone == NULL) {
              if (path == NULL)
                  asprintf(&thermal_zone, THERMAL_ZONE, zone);
              else
                  asprintf(&thermal_zone, path, zone);
          }
          path = thermal_zone;
      }

I think your code will actually not work properly either, because
thermal_zone is a static variable. I think you’ll need to kill that
variable entirely to make multiple instances of the cpu_temperature
module work.

I think inlining the variable is the right thing to do:

        char *thermal_zone;

        if (path == NULL)
                asprintf(&thermal_zone, THERMAL_ZONE, zone);
        else
                asprintf(&thermal_zone, path, zone);

        path = thermal_zone;

        [...]

        free(thermal_zone);


This way multiple instances work - with our without parameter substitution.

Cheers,
  Marco

Reply via email to