Skip to content

Fix warnings in pkg_editor #127

@pcolberg

Description

@pcolberg

Warnings from Ubuntu 22.04 debug build with GCC 11.2:

  • lib/pkg_editor/src/pkg_editor.c

    [84/113] /usr/bin/gcc -DNOMINMAX -DUSE_ZLIB -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/include -g -fPIC -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -MD -MT lib/pkg_editor/CMakeFiles/pkg_editor.dir/src/pkg_editor.c.o -MF lib/pkg_editor/CMakeFiles/pkg_editor.dir/src/pkg_editor.c.o.d -o lib/pkg_editor/CMakeFiles/pkg_editor.dir/src/pkg_editor.c.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'make_string_table_extensible':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:165:16: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'Elf32_Word' {aka 'unsigned int'} may change value [-Wconversion]
      165 |     return data->d_size;
          |            ~~~~^~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:184:14: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'Elf32_Word' {aka 'unsigned int'} may change value [-Wconversion]
      184 |   return data->d_size;
          |          ~~~~^~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_read_file_into_buffer':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:466:15: warning: conversion to 'size_t' {aka 'long unsigned int'} from 'long int' may change the sign of the result [-Wsign-conversion]
      466 |   file_size = ftell(f);
          |               ^~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'set_shdrstrndx':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:784:29: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'Elf32_Word' {aka 'unsigned int'} may change value [-Wconversion]
      784 |     scn_zero_hdr->sh_link = shdrstrndx;
          |                             ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:790:24: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'Elf32_Half' {aka 'short unsigned int'} may change value [-Wconversion]
      790 |     ehdr->e_shstrndx = shdrstrndx;
          |                        ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_open_file':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:976:24: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
      976 |   result->show_error = show_error;
          |                        ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:977:23: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
      977 |   result->show_info = show_info;
          |                       ^~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_open_file_from_memory':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1044:23: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
     1044 |   result->show_info = show_info;
          |                       ^~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1045:24: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
     1045 |   result->show_error = show_error;
          |                        ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_set_show_mode':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1099:22: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
     1099 |     pkg->show_info = show_info;
          |                      ^~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1100:23: warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]
     1100 |     pkg->show_error = show_error;
          |                       ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'append_data':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1120:27: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'uInt' {aka 'unsigned int'} may change value [-Wconversion]
     1120 |   z_info->strm.avail_in = size;
          |                           ^~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'add_file':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:58:20: warning: signed conversion from 'unsigned int' to 'int' changes value from '3203399403' to '-1091567893' [-Wsign-conversion]
       58 | #define PACK_MAGIC 0xBEEFFEEB
          |                    ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1178:16: note: in expansion of macro 'PACK_MAGIC'
     1178 |   info.magic = PACK_MAGIC;
          |                ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1180:20: warning: conversion to 'int' from 'unsigned int' may change the sign of the result [-Wsign-conversion]
     1180 |   info.file_mode = mode;
          |                    ^~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1181:22: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
     1181 |   info.name_length = name_length;
          |                      ^~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'add_directory':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:58:20: warning: signed conversion from 'unsigned int' to 'int' changes value from '3203399403' to '-1091567893' [-Wsign-conversion]
       58 | #define PACK_MAGIC 0xBEEFFEEB
          |                    ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1257:16: note: in expansion of macro 'PACK_MAGIC'
     1257 |   info.magic = PACK_MAGIC;
          |                ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1260:22: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
     1260 |   info.name_length = name_length;
          |                      ^~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'add_file_or_dir':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1394:64: warning: conversion from '__off_t' {aka 'long int'} to 'unsigned int' may change value [-Wconversion]
     1394 |     return add_file(out_file, of, file_or_dir, buf.st_mode, buf.st_size,
          |                                                             ~~~^~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_pack':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:58:20: warning: signed conversion from 'unsigned int' to 'int' changes value from '3203399403' to '-1091567893' [-Wsign-conversion]
       58 | #define PACK_MAGIC 0xBEEFFEEB
          |                    ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1446:16: note: in expansion of macro 'PACK_MAGIC'
     1446 |   info.magic = PACK_MAGIC;
          |                ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'read_data':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1462:28: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'uInt' {aka 'unsigned int'} may change value [-Wconversion]
     1462 |   z_info->strm.avail_out = size;
          |                            ^~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1472:15: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
     1472 |       count = fread(z_info->buffer, 1, sizeof(z_info->buffer), in_fd);
          |               ^~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1477:31: warning: conversion to 'uInt' {aka 'unsigned int'} from 'int' may change the sign of the result [-Wsign-conversion]
     1477 |       z_info->strm.avail_in = count;
          |                               ^~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c: In function 'acl_pkg_unpack_buffer_or_file':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/pkg_editor/src/pkg_editor.c:1532:28: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'uInt' {aka 'unsigned int'} may change value [-Wconversion]
     1532 |     z_info.strm.avail_in = buffer_size;
          |                            ^~~~~~~~~~~
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions