Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8347576

Error output in libjsound has non matching format strings

XMLWordPrintable

    • b07
    • generic
    • generic

      When enabling the jsound ERROR and TRACE reporting (see src/java.desktop/share/native/libjsound/Configure.h https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libjsound/Configure.h#L32 ), we run into these build warnings as errors because at some places the format specifiers do not match the number types :

      /jdk/src/java.desktop/share/native/libjsound/MidiInDevice.c: In function 'Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp':
      /jdk/src/java.desktop/share/native/libjsound/Utilities.h:38:65: error: format '%lld' expects argument of type 'long long int', but argument 3 has type 'jlong' {aka 'long int'} [-Werror=format=]
         38 | #define ERROR1(string, p1) { fprintf(stdout, (string), (p1)); fflush(stdout); }
            | ^~~~~~~~ ~~~~
            | |
            | jlong {aka long int}
      /jdk/src/java.desktop/share/native/libjsound/MidiInDevice.c:140:9: note: in expansion of macro 'ERROR1'
        140 | ERROR1("Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", ret);
            | ^~~~~~
      cc1: all warnings being treated as errors
      * For target support_native_java.desktop_libjsound_MidiOutDevice.o:
      In file included from /jdk/src/java.desktop/share/native/libjsound/MidiOutDevice.c:40:
      /jdk/src/java.desktop/share/native/libjsound/MidiOutDevice.c: In function 'Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp':
      /jdk/src/java.desktop/share/native/libjsound/Utilities.h:38:65: error: format '%lld' expects argument of type 'long long int', but argument 3 has type 'jlong' {aka 'long int'} [-Werror=format=]
         38 | #define ERROR1(string, p1) { fprintf(stdout, (string), (p1)); fflush(stdout); }
            | ^~~~~~~~ ~~~~
            | |
            | jlong {aka long int}
      /jdk/src/java.desktop/share/native/libjsound/MidiOutDevice.c:97:9: note: in expansion of macro 'ERROR1'
         97 | ERROR1("Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", ret);
            | ^~~~~~
      cc1: all warnings being treated as errors

            mbaesken Matthias Baesken
            mbaesken Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: