X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fserial.c;h=1c874e52177e919d59056126015da12edf760109;hb=92445ff3363441d0f515de4a3ab92a504cfc0366;hp=dd063bb53bd9a9707ae5bf2ea74cb9d5b4da03f5;hpb=7e5df1a2c6611bd4ac9fb8ac4b78106f9139ae6e;p=collectd.git diff --git a/src/serial.c b/src/serial.c index dd063bb5..1c874e52 100644 --- a/src/serial.c +++ b/src/serial.c @@ -25,13 +25,10 @@ #include "common.h" #include "plugin.h" -#if defined(KERNEL_LINUX) -# define SERIAL_HAVE_READ 1 -#else -# define SERIAL_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif -#if SERIAL_HAVE_READ static void serial_submit (const char *type_instance, counter_t rx, counter_t tx) { @@ -44,17 +41,17 @@ static void serial_submit (const char *type_instance, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "serial"); - strncpy (vl.type_instance, type_instance, + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "serial", sizeof (vl.plugin)); + sstrncpy (vl.type, "serial_octets", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("serial_octets", &vl); + plugin_dispatch_values (&vl); } static int serial_read (void) { -#ifdef KERNEL_LINUX FILE *fh; char buffer[1024]; @@ -121,13 +118,9 @@ static int serial_read (void) fclose (fh); return (0); -#endif /* KERNEL_LINUX */ } /* int serial_read */ -#endif /* SERIAL_HAVE_READ */ void module_register (void) { -#if SERIAL_HAVE_READ plugin_register_read ("serial", serial_read); -#endif /* SERIAL_HAVE_READ */ } /* void module_register */