]> sigrok.org Git - libsigrok.git/commitdiff
drivers: don't try to access the sr_driver_list section with no driver compiled.
authorAurelien Jacobs <redacted>
Sun, 14 Aug 2016 23:28:55 +0000 (01:28 +0200)
committerAurelien Jacobs <redacted>
Sun, 14 Aug 2016 23:45:50 +0000 (01:45 +0200)
This closes bug #820.

configure.ac
src/drivers.c

index c5089f1db4ee3132f59f6ca2bcf2e5ffd0e5b181..94e545720ba07c80d9dce57411b149070aebbed3 100644 (file)
@@ -211,7 +211,7 @@ m4_define([_SR_DRIVER], [
        sr_driver_summary_append "$2" "$sr_hw_info"
 
        AM_CONDITIONAL([$3], [test "x[$]$3" = xyes])
-       AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.])])
+       AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.]) AC_DEFINE([HAVE_DRIVERS], [1], [Whether at least one driver is enabled.])])
 ])
 
 ## SR_DRIVER(Device name, driver-name, [dependencies...])
index a5c21a08097de35395e4d9d98b322867b93c9779..d2763414acb8ae79f389ca519989f3d1332a62da 100644 (file)
@@ -18,6 +18,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <glib.h>
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
@@ -44,13 +45,14 @@ extern struct sr_dev_driver *__stop_sr_driver_list;
  */
 SR_API void sr_drivers_init(struct sr_context *ctx)
 {
-       struct sr_dev_driver **drivers;
        GArray *array;
 
        array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
-       for (drivers = &__start_sr_driver_list; drivers < &__stop_sr_driver_list;
-               drivers++)
+#ifdef HAVE_DRIVERS
+       for (struct sr_dev_driver **drivers = &__start_sr_driver_list;
+            drivers < &__stop_sr_driver_list; drivers++)
                g_array_append_val(array, *drivers);
+#endif
        ctx->driver_list = (struct sr_dev_driver **)array->data;
        g_array_free(array, FALSE);
 }