chiark / gitweb /
regress/hplayback: Break out Pfgets
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 11 Sep 2026 12:19:46 +0000 (13:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 11 Sep 2026 12:24:23 +0000 (13:24 +0100)
This is more DRY and allows us to try to suppress an unused return
value warning.

regress/hplayback.c.m4

index 7e688bf1eac04f7ca2c5937ab17b16d87f7933e8..4fd9b5ca206eb3dd93bdc0708bf4ca565962762f 100644 (file)
@@ -92,6 +92,12 @@ static void Pcheckinput(void) {
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
 
+
+static void Pfgets(void *buf, int size) {
+  (void)fgets(buf,size,Tinputfile);
+  Pcheckinput();
+}
+
 void T_gettimeofday_hook(void) {
   static struct timeval previously;
   struct timeval delta;
@@ -118,7 +124,7 @@ void Tensuresetup(void) {
   setvbuf(Tinputfile,0,_IONBF,0);
 
   if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
-  fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+  Pfgets(vb2.buf,vb2.avail);
   chars= -1;
   sscanf(vb2.buf," start %lu.%lu%n",&sec,&usec,&chars);
   if (chars==-1) Psyntax("start time invalid");
@@ -170,7 +176,7 @@ static void P_updatetime(void) {
   long usec;
 
   if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
-  fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+  Pfgets(vb2.buf,vb2.avail);
   chars= -1;
   sscanf(vb2.buf," +%lu.%ld%n",&sec,&usec,&chars);
   if (chars==-1) Psyntax("update time invalid");
@@ -388,7 +394,7 @@ int H$1(hm_args_massage($3,void)) {
 
  m4_define(`hm_r_offset',`m4_len(` $1=')')
  if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
Pfgets(vb2.buf,vb2.avail);
 
  Tensuresetup();
  fprintf(Treportfile,"%s",vb2.buf);