examples/slcd: fix priv->fd that was used by slcd_flush before being set

This commit is contained in:
Pierre-Olivier Vauboin 2020-03-18 14:56:27 +01:00 committed by Gregory Nutt
parent e1d9e82273
commit f17d89d085

View File

@ -267,7 +267,7 @@ int main(int argc, FAR char *argv[])
printf("Opening %s for read/write access\n", CONFIG_EXAMPLES_SLCD_DEVNAME); printf("Opening %s for read/write access\n", CONFIG_EXAMPLES_SLCD_DEVNAME);
fd = open(CONFIG_EXAMPLES_SLCD_DEVNAME, O_RDWR); fd = open(CONFIG_EXAMPLES_SLCD_DEVNAME, O_RDWR);
if (priv->fd < 0) if (fd < 0)
{ {
printf("Failed to open %s: %d\n", CONFIG_EXAMPLES_SLCD_DEVNAME, errno); printf("Failed to open %s: %d\n", CONFIG_EXAMPLES_SLCD_DEVNAME, errno);
goto errout; goto errout;
@ -286,6 +286,7 @@ int main(int argc, FAR char *argv[])
#ifdef CONFIG_STDIO_LINEBUFFER #ifdef CONFIG_STDIO_LINEBUFFER
priv->stream.flush = slcd_flush; priv->stream.flush = slcd_flush;
#endif #endif
priv->fd = fd;
/* Get the attributes of the SCLD device */ /* Get the attributes of the SCLD device */