Bug 103050 - Fix warnings and cleanup unused defs
Summary: Fix warnings and cleanup unused defs
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-01 09:13 UTC by Adrian Johnson
Modified: 2017-11-13 17:13 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix warning: comparison of unsigned expression (1.58 KB, patch)
2017-10-01 09:13 UTC, Adrian Johnson
Details | Splinter Review
Fix warning implicit declaration of function (1.29 KB, patch)
2017-10-01 09:14 UTC, Adrian Johnson
Details | Splinter Review
Fix deprecated warnings in glib demo (1.37 KB, patch)
2017-10-01 09:15 UTC, Adrian Johnson
Details | Splinter Review
Fix some -Wundef warnings (59.89 KB, patch)
2017-10-01 09:16 UTC, Adrian Johnson
Details | Splinter Review
Use _WIN32 instead of WIN32 (3.36 KB, patch)
2017-10-01 09:17 UTC, Adrian Johnson
Details | Splinter Review
Remove unused t1lib code for the obsolete t1lib library (29.05 KB, patch)
2017-10-01 09:19 UTC, Adrian Johnson
Details | Splinter Review
Remove freetype macros (13.88 KB, patch)
2017-10-01 09:19 UTC, Adrian Johnson
Details | Splinter Review
Fix remaining -Wundef warnings and make -Wundef a default warning (45.00 KB, patch)
2017-10-01 09:20 UTC, Adrian Johnson
Details | Splinter Review
Use cstdint and drop the stdint checks and emulation (4.68 KB, patch)
2017-10-01 09:21 UTC, Adrian Johnson
Details | Splinter Review
Remove HAVE_CONFIG_H macro (1005 bytes, patch)
2017-10-01 09:21 UTC, Adrian Johnson
Details | Splinter Review
Remove unused config.h macros (4.07 KB, patch)
2017-10-01 09:22 UTC, Adrian Johnson
Details | Splinter Review
HAVE_PTHREAD is not used (657 bytes, patch)
2017-10-01 10:22 UTC, Adrian Johnson
Details | Splinter Review
Use -pthread instead of -lpthread when compiling (3.29 KB, patch)
2017-10-02 01:37 UTC, Adrian Johnson
Details | Splinter Review
Make poppler compile of threads not available (1.08 KB, patch)
2017-10-02 01:43 UTC, Adrian Johnson
Details | Splinter Review
Remove unused HAVE_ZLIB_H/HAVE_LIBZ (1.05 KB, patch)
2017-10-02 02:27 UTC, Adrian Johnson
Details | Splinter Review
move macros out of poppler-config.h that don't need to be there (1.96 KB, patch)
2017-10-02 03:25 UTC, Adrian Johnson
Details | Splinter Review
Move strtok_r emulation to goo/glibc (3.73 KB, patch)
2017-10-02 03:26 UTC, Adrian Johnson
Details | Splinter Review
Use cmath and remove fmin/fmax from poppler-config.h (1.16 KB, patch)
2017-10-02 03:26 UTC, Adrian Johnson
Details | Splinter Review
stdio.h not needed in poppler-config.h (783 bytes, patch)
2017-10-02 03:27 UTC, Adrian Johnson
Details | Splinter Review
c++ has long long (5.63 KB, patch)
2017-10-02 04:47 UTC, Adrian Johnson
Details | Splinter Review
c++ has long long (7.20 KB, patch)
2017-10-02 06:35 UTC, Adrian Johnson
Details | Splinter Review
use <cmath> for isfinite (1.18 KB, patch)
2017-10-02 06:35 UTC, Adrian Johnson
Details | Splinter Review
Remove VC7 workaround (1.09 KB, patch)
2017-10-02 06:36 UTC, Adrian Johnson
Details | Splinter Review
mingw threads fix (1.04 KB, patch)
2017-10-02 10:00 UTC, Adrian Johnson
Details | Splinter Review
mingw warnings fix (4.21 KB, patch)
2017-10-02 10:00 UTC, Adrian Johnson
Details | Splinter Review
mingw warnings fix (4.10 KB, patch)
2017-10-02 10:03 UTC, Adrian Johnson
Details | Splinter Review
mingw warnings fix (3.70 KB, patch)
2017-10-05 21:08 UTC, Adrian Johnson
Details | Splinter Review
Fix warning: comparison of unsigned expression v2 (1.58 KB, patch)
2017-10-18 09:39 UTC, Adrian Johnson
Details | Splinter Review
Fix warning implicit declaration of function v2 (1.60 KB, patch)
2017-10-18 09:42 UTC, Adrian Johnson
Details | Splinter Review
mingw warnings fix v2 (3.99 KB, patch)
2017-10-18 10:18 UTC, Adrian Johnson
Details | Splinter Review
glib demo: correct the previous warnings fix (1.69 KB, patch)
2017-10-22 08:13 UTC, Adrian Johnson
Details | Splinter Review
Fix selections warning (973 bytes, patch)
2017-11-10 19:11 UTC, Adrian Johnson
Details | Splinter Review

Description Adrian Johnson 2017-10-01 09:13:15 UTC
Created attachment 134579 [details] [review]
Fix warning: comparison of unsigned expression
Comment 1 Adrian Johnson 2017-10-01 09:14:17 UTC
Created attachment 134580 [details] [review]
Fix warning implicit declaration of function
Comment 2 Adrian Johnson 2017-10-01 09:15:42 UTC
Created attachment 134581 [details] [review]
Fix deprecated warnings in glib demo

There is one deprecated warning remaining in the glib demo. Carlos, could you have a look. I don't know how to fix it.
Comment 3 Adrian Johnson 2017-10-01 09:16:10 UTC
Created attachment 134582 [details] [review]
Fix some -Wundef warnings
Comment 4 Adrian Johnson 2017-10-01 09:17:08 UTC
Created attachment 134583 [details] [review]
Use _WIN32 instead of WIN32
Comment 5 Adrian Johnson 2017-10-01 09:19:10 UTC
Created attachment 134584 [details] [review]
Remove unused t1lib code for the obsolete t1lib library
Comment 6 Adrian Johnson 2017-10-01 09:19:33 UTC
Created attachment 134585 [details] [review]
Remove freetype macros
Comment 7 Adrian Johnson 2017-10-01 09:20:18 UTC
Created attachment 134586 [details] [review]
Fix remaining -Wundef warnings and make -Wundef a default warning
Comment 8 Adrian Johnson 2017-10-01 09:21:10 UTC
Created attachment 134587 [details] [review]
Use cstdint and drop the stdint checks and emulation
Comment 9 Adrian Johnson 2017-10-01 09:21:52 UTC
Created attachment 134588 [details] [review]
Remove HAVE_CONFIG_H macro
Comment 10 Adrian Johnson 2017-10-01 09:22:27 UTC
Created attachment 134589 [details] [review]
Remove unused config.h macros
Comment 11 Adrian Johnson 2017-10-01 10:22:51 UTC
Created attachment 134592 [details] [review]
HAVE_PTHREAD is not used

And one more I missed.
Comment 12 Adrian Johnson 2017-10-02 01:37:54 UTC
Created attachment 134603 [details] [review]
Use -pthread instead of -lpthread when compiling
Comment 13 Adrian Johnson 2017-10-02 01:43:52 UTC
Created attachment 134604 [details] [review]
Make poppler compile of threads not available

This makes poppler compile if no thread library is found.

The 77 instances of #ifdef MULTITHREADED could be removed if we changed the GooMutex class so that it is always included but the functions are a no op if MULTITHREADED is not defined.
Comment 14 Adrian Johnson 2017-10-02 02:27:56 UTC
Created attachment 134605 [details] [review]
Remove unused HAVE_ZLIB_H/HAVE_LIBZ

More unused macros
Comment 15 Adrian Johnson 2017-10-02 03:25:06 UTC
Created attachment 134606 [details] [review]
move macros out of poppler-config.h that don't need to be there
Comment 16 Adrian Johnson 2017-10-02 03:26:08 UTC
Created attachment 134607 [details] [review]
Move strtok_r emulation to goo/glibc
Comment 17 Adrian Johnson 2017-10-02 03:26:52 UTC
Created attachment 134608 [details] [review]
Use cmath and remove fmin/fmax from poppler-config.h
Comment 18 Adrian Johnson 2017-10-02 03:27:19 UTC
Created attachment 134609 [details] [review]
stdio.h not needed in poppler-config.h
Comment 19 Adrian Johnson 2017-10-02 04:47:17 UTC
Created attachment 134610 [details] [review]
c++ has long long
Comment 20 Adrian Johnson 2017-10-02 06:35:29 UTC
Created attachment 134611 [details] [review]
c++ has long long
Comment 21 Adrian Johnson 2017-10-02 06:35:55 UTC
Created attachment 134612 [details] [review]
use <cmath> for isfinite
Comment 22 Adrian Johnson 2017-10-02 06:36:17 UTC
Created attachment 134613 [details] [review]
Remove VC7 workaround
Comment 23 Adrian Johnson 2017-10-02 10:00:06 UTC
Created attachment 134617 [details] [review]
mingw threads fix
Comment 24 Adrian Johnson 2017-10-02 10:00:29 UTC
Created attachment 134618 [details] [review]
mingw warnings fix
Comment 25 Adrian Johnson 2017-10-02 10:03:13 UTC
Created attachment 134619 [details] [review]
mingw warnings fix
Comment 26 Albert Astals Cid 2017-10-05 17:05:22 UTC
I'm aware of this, but will have to wait at least until tuesday/wednesday next week until i can have a look.
Comment 27 Adrian Johnson 2017-10-05 21:08:21 UTC
Created attachment 134692 [details] [review]
mingw warnings fix
Comment 28 Albert Astals Cid 2017-10-16 22:11:51 UTC
> Fix warning: comparison of unsigned expression
Can you keep the const?
Comment 29 Albert Astals Cid 2017-10-16 22:12:36 UTC
> Fix warning implicit declaration of function
Going to need some more explanation of what this actually fixes.
Comment 30 Albert Astals Cid 2017-10-16 22:13:09 UTC
> Fix deprecated warnings in glib demo

I'll leave this for someone that knows gstuff
Comment 31 Albert Astals Cid 2017-10-16 22:16:28 UTC
> Fix some -Wundef warnings

I'm actually kind of scared of this patch, we kind of know "it works" as of now, and changing this is kind of fragile, but ok i guess
Comment 32 Albert Astals Cid 2017-10-16 22:17:20 UTC
> Use _WIN32 instead of WIN32

I've no idea about windows, if you know this is correct go ahead, if not sure find someone else to have a look :)
Comment 33 Albert Astals Cid 2017-10-16 22:19:41 UTC
> Remove unused t1lib code for the obsolete t1lib library

-// or cmake: DISABLE_OUTLINE, DEBUG_MEM, SPLASH_CMYK, HAVE_T1LIB_H,
+// or cmake: DISABLE_OUTLINE, DEBUG_MEM,

You removed SPLASH_CMYK by mistake i guess

otherwise, fine
Comment 34 Albert Astals Cid 2017-10-16 22:21:31 UTC
> Remove freetype macros
Ok
Comment 35 Albert Astals Cid 2017-10-16 22:22:29 UTC
> Fix remaining -Wundef warnings and make -Wundef a default warning

Again very scared about this, but if you're sure it's fine, go ahead.
Comment 36 Albert Astals Cid 2017-10-16 22:23:03 UTC
> Use cstdint and drop the stdint checks and emulation
Ok
Comment 37 Albert Astals Cid 2017-10-16 22:24:59 UTC
> Remove HAVE_CONFIG_H macro
Ok
Comment 38 Albert Astals Cid 2017-10-16 22:27:31 UTC
> Remove unused config.h macros

the HAVE_BOOLEAN seems like something we should keep? In case someone there is using whatever UNIXWARE is
Comment 39 Albert Astals Cid 2017-10-16 22:28:09 UTC
> HAVE_PTHREAD is not used
Ok
Comment 40 Albert Astals Cid 2017-10-16 22:29:48 UTC
> Use -pthread instead of -lpthread when compiling
Ok
Comment 41 Albert Astals Cid 2017-10-16 22:31:28 UTC
> Make poppler compile of threads not available

I don't understand this one, please explain the rationale of it
Comment 42 Albert Astals Cid 2017-10-16 22:32:16 UTC
> Remove unused HAVE_ZLIB_H/HAVE_LIBZ
Ok
Comment 43 Albert Astals Cid 2017-10-16 22:32:46 UTC
> move macros out of poppler-config.h that don't need to be there
ok
Comment 44 Albert Astals Cid 2017-10-16 22:33:41 UTC
>  Move strtok_r emulation to goo/glibc
Ok
Comment 45 Albert Astals Cid 2017-10-16 22:34:38 UTC
> Use cmath and remove fmin/fmax from poppler-config.h
Ok
Comment 46 Albert Astals Cid 2017-10-16 22:36:06 UTC
>  stdio.h not needed in poppler-config.h
Are you totally sure about that? Who defines the printf __format__ attributes? i've no idea but seems like they may actually come from stdio.h
Comment 47 Albert Astals Cid 2017-10-16 22:36:53 UTC
>  c++ has long long 
ok
Comment 48 Albert Astals Cid 2017-10-16 22:37:13 UTC
> use <cmath> for isfinite
Ok
Comment 49 Albert Astals Cid 2017-10-16 22:37:36 UTC
>  Remove VC7 workaround
Ok
Comment 50 Albert Astals Cid 2017-10-16 22:39:08 UTC
>  mingw threads fix
ok
Comment 51 Albert Astals Cid 2017-10-16 22:39:16 UTC
> mingw warnings fix
ok
Comment 52 Adrian Johnson 2017-10-18 09:39:12 UTC
Created attachment 134903 [details] [review]
Fix warning: comparison of unsigned expression v2

Restore const.
Comment 53 Adrian Johnson 2017-10-18 09:42:07 UTC
Created attachment 134904 [details] [review]
Fix warning implicit declaration of function v2

Add explanation to commit
Comment 54 Adrian Johnson 2017-10-18 09:45:33 UTC
(In reply to Albert Astals Cid from comment #30)
> > Fix deprecated warnings in glib demo
> 
> I'll leave this for someone that knows gstuff

Carlos, could you review this. Also there is one glib demo deprecated warning remaining that I don't know how to fix.
Comment 55 Adrian Johnson 2017-10-18 09:53:30 UTC
(In reply to Albert Astals Cid from comment #31)
> > Fix some -Wundef warnings
> 
> I'm actually kind of scared of this patch, we kind of know "it works" as of
> now, and changing this is kind of fragile, but ok i guess

I don't want to commit anything your not entirely happy with. What specifically concerns you about the patch? It just changes #if ... to #if defined() or #ifdef for the feature macros. It is less fragile than the existing code where someone could make a typo eg 
#if ENABLED_LIBZ /* should be ENABLED_ZLIB */

and the code will compile without warnings.
Comment 56 Adrian Johnson 2017-10-18 09:55:00 UTC
(In reply to Albert Astals Cid from comment #32)
> > Use _WIN32 instead of WIN32
> 
> I've no idea about windows, if you know this is correct go ahead, if not
> sure find someone else to have a look :)

It is correct. We did fix most of them a long time ago but a few got missed (or added later - I didn't check the history).
Comment 57 Adrian Johnson 2017-10-18 09:57:38 UTC
(In reply to Albert Astals Cid from comment #33)
> > Remove unused t1lib code for the obsolete t1lib library
> 
> -// or cmake: DISABLE_OUTLINE, DEBUG_MEM, SPLASH_CMYK, HAVE_T1LIB_H,
> +// or cmake: DISABLE_OUTLINE, DEBUG_MEM,
> 
> You removed SPLASH_CMYK by mistake i guess

It wasn't a mistake. SPLASH_CMYK is now an option defined in CMakeLists.txt.

> 
> otherwise, fine
Comment 58 Adrian Johnson 2017-10-18 10:06:03 UTC
(In reply to Albert Astals Cid from comment #38)
> > Remove unused config.h macros
> 
> the HAVE_BOOLEAN seems like something we should keep? In case someone there
> is using whatever UNIXWARE is

UnixWare removed "boolean" from user namespace in 2004:

ftp://ftp.sco.com/pub/unixware7/713/uw713up/relnotes-up4.html

  "104. Change the "enum boolean" tag in /usr/include/sys/types.h to "enum
   __boolean", removing the type/tag "boolean" from the user name space."

I don't think it likely that anyone would try building a 2017 poppler on a 2004 UnixWare, particularly with the C++11 requirement.
Comment 59 Adrian Johnson 2017-10-18 10:13:21 UTC
(In reply to Albert Astals Cid from comment #41)
> > Make poppler compile of threads not available
> 
> I don't understand this one, please explain the rationale of it

We've got 77 "#ifdef MULTITHREADED" macros all over the code but MULTITHREADED is always defined. We should either define MULTITHREADED based on whether threads have been detected or just remove the macro. The former allows users to build on systems without threads.

Although the best solution IMHO is too add a no op version of the mutex class to GooMutex.h for when threads are not available then all the MULTITHREADED macros can be removed.
Comment 60 Adrian Johnson 2017-10-18 10:18:06 UTC
Created attachment 134906 [details] [review]
mingw warnings fix v2

(In reply to Albert Astals Cid from comment #46)
> >  stdio.h not needed in poppler-config.h
> Are you totally sure about that? Who defines the printf __format__
> attributes? i've no idea but seems like they may actually come from stdio.h

I found when compiling in mingw it is needed and added it back just above the MINGW_PRINTF_FORMAT with a comment explaining why it is needed. Removed the stdio patch and rebased the mingw warnings patch.
Comment 61 Albert Astals Cid 2017-10-20 15:39:21 UTC
(In reply to Adrian Johnson from comment #55)
> (In reply to Albert Astals Cid from comment #31)
> > > Fix some -Wundef warnings
> > 
> > I'm actually kind of scared of this patch, we kind of know "it works" as of
> > now, and changing this is kind of fragile, but ok i guess
> 
> I don't want to commit anything your not entirely happy with. What
> specifically concerns you about the patch? It just changes #if ... to #if
> defined() or #ifdef for the feature macros. It is less fragile than the
> existing code where someone could make a typo eg 
> #if ENABLED_LIBZ /* should be ENABLED_ZLIB */
> 
> and the code will compile without warnings.

Before a
   #define Foo 0
would go in one way of the branch and now would go on the other, but since the build system doens't really create any define to 0 i guess we're fine
Comment 62 Albert Astals Cid 2017-10-20 15:45:38 UTC
(In reply to Adrian Johnson from comment #59)
> (In reply to Albert Astals Cid from comment #41)
> > > Make poppler compile of threads not available
> > 
> > I don't understand this one, please explain the rationale of it
> 
> We've got 77 "#ifdef MULTITHREADED" macros all over the code but
> MULTITHREADED is always defined. We should either define MULTITHREADED based
> on whether threads have been detected or just remove the macro. The former
> allows users to build on systems without threads.
> 
> Although the best solution IMHO is too add a no op version of the mutex
> class to GooMutex.h for when threads are not available then all the
> MULTITHREADED macros can be removed.

Hmmm, ok i guess, to be honest i think we shouldn't really worry much about the non multithreaded case, how did you test this? which system without thread support did you use?
Comment 63 Albert Astals Cid 2017-10-20 15:46:45 UTC
Ok, so everything except the gtk demo look ok to me and that one i don't have any idea but if it fixes it for you i guess you can commit, if it breaks, well it's the demo after all and we can fix it.
Comment 64 Adrian Johnson 2017-10-21 10:45:19 UTC
Pushed
Comment 65 Carlos Garcia Campos 2017-10-22 07:20:28 UTC
Comment on attachment 134581 [details] [review]
Fix deprecated warnings in glib demo

Review of attachment 134581 [details] [review]:
-----------------------------------------------------------------

::: glib/demo/utils.c
@@ +274,5 @@
>  		uri = g_file_get_uri (file);
>  		g_object_unref (file);
>  		if (uri) {
> +#if GTK_CHECK_VERSION(3, 22, 0)
> +			gtk_show_uri_on_window (GTK_WINDOW(gtk_widget_get_window (button)),

This is not correct. gtk_show_uri_on_window() expects a GtkWindow, but gtk_widget_get_window() returns a GdkWindow (which is not a toplevel window). To get the toplevel window of a widget you can use something like this:

toplevel = gtk_widget_get_toplevel (button);
gtk_show_uri_on_window (gtk_widget_is_toplevel (toplevel) ? GTK_WINDOW (toplevel) : NULL,

@@ +542,5 @@
>  	uri = g_file_get_uri (file);
>  	g_object_unref (file);
>  	if (uri) {
> +#if GTK_CHECK_VERSION(3, 22, 0)
> +	    gtk_show_uri_on_window (GTK_WINDOW(gtk_widget_get_window (button)),

Ditto.
Comment 66 Adrian Johnson 2017-10-22 08:13:55 UTC
Created attachment 134985 [details] [review]
glib demo: correct the previous warnings fix

Does this look good?

Also, do you have any idea how to fix this warning?

../glib/demo/selections.c: In function ‘pgd_selections_drawing_area_realize’:
../glib/demo/selections.c:340:9: warning: ‘gtk_style_context_get_background_color’ is deprecated: Use 'gtk_render_background' instead [-Wdeprecated-declarations]
Comment 67 Carlos Garcia Campos 2017-10-28 05:56:16 UTC
(In reply to Adrian Johnson from comment #66)
> Created attachment 134985 [details] [review] [review]
> glib demo: correct the previous warnings fix
> 
> Does this look good?

Yes.

> Also, do you have any idea how to fix this warning?
> 
> ../glib/demo/selections.c: In function ‘pgd_selections_drawing_area_realize’:
> ../glib/demo/selections.c:340:9: warning:
> ‘gtk_style_context_get_background_color’ is deprecated: Use
> 'gtk_render_background' instead [-Wdeprecated-declarations]

You can probably do:

GdkRGBA *rgba;

gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED, "background-color", &rgba, NULL);
.....
gdk_rgba_free (rgba);
Comment 68 Adrian Johnson 2017-11-10 19:11:53 UTC
Created attachment 135378 [details] [review]
Fix selections warning

Patch to fix the last remaining glib warning
Comment 69 Carlos Garcia Campos 2017-11-13 17:13:17 UTC
(In reply to Adrian Johnson from comment #68)
> Created attachment 135378 [details] [review] [review]
> Fix selections warning
> 
> Patch to fix the last remaining glib warning

Thanks, please push it too.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.