From: Peter Stuge Date: Sun, 21 Oct 2012 18:43:32 +0000 (+0200) Subject: Add struct sr_context * to sr_driver_init() calls X-Git-Tag: sigrok-cli-0.4.0~67 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e2fe62cc46b53689105f2434c35cabb238f369b0;p=sigrok-cli.git Add struct sr_context * to sr_driver_init() calls libsigrok.git commit 193691ae1590eb31025d943ffbb0ea5c1047e6ca changes the API of sr_driver_init() to take a struct sr_context * parameter as allocated by sr_init(). Move our struct sr_context *sr_ctx out of main() into file global scope so that it can be used easily in all calls to sr_driver_init(). --- diff --git a/sigrok-cli.c b/sigrok-cli.c index 4af47d2..3673536 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -36,6 +36,8 @@ #define DEFAULT_OUTPUT_FORMAT "bits:width=64" +static struct sr_context *sr_ctx = NULL; + static uint64_t limit_samples = 0; static uint64_t limit_frames = 0; static struct sr_output_format *output_format = NULL; @@ -162,7 +164,7 @@ static GSList *device_scan(void) return NULL; } g_free(drvname); - if (sr_driver_init(driver) != SR_OK) { + if (sr_driver_init(sr_ctx, driver) != SR_OK) { g_critical("Failed to initialize driver."); return NULL; } @@ -178,7 +180,7 @@ static GSList *device_scan(void) drivers = sr_driver_list(); for (i = 0; drivers[i]; i++) { driver = drivers[i]; - if (sr_driver_init(driver) != SR_OK) { + if (sr_driver_init(sr_ctx, driver) != SR_OK) { g_critical("Failed to initialize driver."); return NULL; } @@ -1476,7 +1478,6 @@ int main(int argc, char **argv) int ret = 1; GOptionContext *context; GError *error; - struct sr_context *sr_ctx = NULL; g_log_set_default_handler(logger, NULL);