0

installing festival speech synthesis system from http://festvox.org/ ...directly by running general script. Facing below given problem .....this problem will effect my working on festival framework or not ?????

eps.c: In function ‘getd’:

eps.c:142:7: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

   fscanf(fp, "%d %d", x, y);
   ^
  • 1
    What is your question? Furthermore, notice that a *warning* is not always an *error.* – fuz Aug 23 '15 at 12:06

3 Answers3

3

Read documentation of fscanf(3). You should use the returned count of successfully scanned items, e.g. code something like:

int x = 0, y = 0;
if (fscanf(fp, "%d %d", &x, &y) < 2) {
   fprintf(stderr, "missing numbers at offset %ld\n", ftell(fp));
   exit(EXIT_FAILURE);
}

so you could improve the eps.c file (and perhaps submit a patch and/or a bug report upstream).

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

This warning says that not checking the return value of scanf is not a really good idea.

I thought casting to (void) was a way to avoid that but apparently it is not as discussed here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509

However it is not an error that you get but just a warning (your title is kinda misleading)

If the value is not used it is clearly not a problem.

LBes
  • 3,366
  • 1
  • 32
  • 66
  • okhay ya i got it....thanks Great !!!...............should i continue my further installation of festival speech synthesis system ..without taking so much attention to this warning ..??????????? – Sukhpreet Gill Aug 23 '15 at 13:22
  • I can't really say as I've never used that before. If I were you I would continue the installation and if you have any issue in the future get back to that warning. Remember to set as marked if the answer helped you :) – LBes Aug 23 '15 at 13:24
0

The man page say:

The value EOF is returned if the end of input is reached before either the first successful conversion or a matching failure occurs. EOF is also returned if a read error occurs, in which case the error indicator for the stream (see ferror(3)) is set, and errno is set to indicate the error.

This means that you can check against EOF:

#include<stdio.h>

int main(void){
    int a;
    printf("Please give the value of A: ");

    if(scanf("%d",&a) != EOF){
        printf("\nThe value of A is\t%d\n",a);
    }

    return 0;
}

Or:

#include<stdio.h>
#include <errno.h>
#include<string.h>

int main(void){
    int a, errnum = errno;
    printf("Please give the value of A: ");

    if(scanf("%d",&a) == EOF){
        fprintf(stderr, "Value of errno: %d\n", errno);
        perror("Error printed by perror");
        fprintf(stderr, "Error opening file: %s\n", strerror( errnum ));
    }

    printf("\nThe value of A is\t%d\n",a);
    return 0;
}

This applies for:

scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf - input format con‐ version

Michi
  • 5,175
  • 7
  • 33
  • 58
  • 1
    Not a good answer, if one number was input with a format `"%d %d"` asking for two (i.e. `scanf("%d %d", &x, &y)` giving only 1...) – Basile Starynkevitch Aug 23 '15 at 13:45
  • @Basile Starynkevitch Sir, the answer was related to just one not two, whatever. Fell free to be not agree with my answer. If you really want to speak about how is good or wrong, this is what i always use ==>> http://stackoverflow.com/questions/31770861/validate-parameter-for-0-or-1/31772378#31772378 – Michi Aug 23 '15 at 15:25
  • Then the test should be `if (scanf("%d", &x)<1)` (which includes the `EOF` case, since `EOF` is known to be negative) – Basile Starynkevitch Aug 23 '15 at 17:24