RTEMS Tools | misc/bin2c/rtems-bin2c.c: Add feature to include license header in generated C files (!58)

Christian Mauderer (@c-mauderer) gitlab at rtems.org
Wed Apr 2 06:52:46 UTC 2025




Christian Mauderer started a new discussion on misc/bin2c/rtems-bin2c.c: https://gitlab.rtems.org/rtems/tools/rtems-tools/-/merge_requests/58#note_121998

 > +
 > +  if (fseek(file, 0, SEEK_SET) != 0) {
 > +    perror("error: could not seek to start of license file");
 > +    fclose(file);
 > +    exit(1);
 > +  }
 > +
 > +  buffer = malloc(length + 1);
 > +  if (!buffer) {
 > +    perror("error: could not allocate memory for license file");
 > +    fclose(file);
 > +    exit(1);
 > +  }
 > +
 > +  readsize = fread(buffer, 1, length, file);
 > +  if (readsize != length) {

This line is causing a warning:
```
../misc/bin2c/rtems-bin2c.c: In function ‘read_license_file’:                                                                                                                                                     
../misc/bin2c/rtems-bin2c.c:98:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]                                                                                           
   if (readsize != length) {                                                                                                                                                                                      
                ^~
```
The return types are specified by the functions `ftell` and `fread` so you can't change the type. Therefore I would recommend a cast here to silence the warning.

I'm OK with the rest of the merge request now.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/tools/rtems-tools/-/merge_requests/58#note_121998
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250402/fbcc7dbf/attachment-0001.htm>


More information about the bugs mailing list