IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40549


Ignore:
Timestamp:
Oct 20, 2018, 8:58:31 PM (8 years ago)
Author:
eugene
Message:

add snprintf_nowarn function to avoid compiler warnings from desired snprint truncations

Location:
trunk/Ohana/src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/loadICRF_save_remote.c

    r38441 r40549  
    88  int TIME = time(NULL);
    99  int PID = getpid();
    10   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     10  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1111
    1212  // if this region is a parallel thing, save and launch remote
  • trunk/Ohana/src/addstar/src/loadstarpar_save_remote.c

    r38986 r40549  
    88  int TIME = time(NULL);
    99  int PID = getpid();
    10   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     10  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1111
    1212  // if this region is a parallel thing, save and launch remote
  • trunk/Ohana/src/addstar/src/setobjflags_save_remote.c

    r39535 r40549  
    88  int TIME = time(NULL);
    99  int PID = getpid();
    10   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     10  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1111
    1212  // if this region is a parallel thing, save and launch remote
  • trunk/Ohana/src/checkastro/src/load_catalogs.c

    r38471 r40549  
    102102  int TIME = time(NULL);
    103103  int PID = getpid();
    104   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     104  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    105105
    106106  // load the list of hosts
  • trunk/Ohana/src/delstar/src/delete_fix_LAP.c

    r39457 r40549  
    8888  int TIME = time(NULL);
    8989  int PID = getpid();
    90   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     90  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    9191
    9292  // write out the subset table of image information
  • trunk/Ohana/src/delstar/src/delete_fix_LAP_edges.c

    r38471 r40549  
    8787  int TIME = time(NULL);
    8888  int PID = getpid();
    89   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     89  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    9090
    9191  // launch the delstar_client jobs to the parallel hosts
  • trunk/Ohana/src/delstar/src/delete_fix_LAP_edges_delete.c

    r38986 r40549  
    138138  int TIME = time(NULL);
    139139  int PID = getpid();
    140   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     140  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    141141
    142142  // launch the delstar_client jobs to the parallel hosts
  • trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps.c

    r38471 r40549  
    121121  int TIME = time(NULL);
    122122  int PID = getpid();
    123   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     123  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    124124
    125125  int i;
  • trunk/Ohana/src/fakeastro/src/save_fakestars.c

    r38441 r40549  
    77  int TIME = time(NULL);
    88  int PID = getpid();
    9   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     9  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1010
    1111  // if this region is a parallel thing, save and launch remote
  • trunk/Ohana/src/gastro2/src/lumfunc.c

    r27491 r40549  
    1616  lum[0].dNdM = lum[0].Mo = 0;
    1717
    18   bzero (mbin, NMBIN * sizeof (double));
     18  // use 'explicit_bzero' to avoid optimizations compile warnings
     19  explicit_bzero (mbin, NMBIN * sizeof (double));
    1920
    2021  /* sum histogram */
  • trunk/Ohana/src/libdvo/src/convert.c

    r39523 r40549  
    224224
    225225  if (deg < 0) {
    226     snprintf (line, 16, "-%02d:%04.1f", abs(hr), mn);
     226    snprintf_nowarn (line, 16, "-%02d:%04.1f", abs(hr), mn);
    227227  } else {
    228     snprintf (line, 16, "+%02d:%04.1f", hr, mn);
     228    snprintf_nowarn (line, 16, "+%02d:%04.1f", hr, mn);
    229229  }     
    230230  return (line);
  • trunk/Ohana/src/libfits/matrix/F_uncompress_M.c

    r39457 r40549  
    9898    gfits_delete (header, "ZTILE1", 1);
    9999    for (axis = 1; axis < header->Naxes; axis++) {
    100       snprintf (key, 10, "ZTILE%d", axis + 1);
     100      snprintf (key, 10, "ZTILE%d", axis + 1); 
    101101      if (!gfits_scan (header, key, "%lu", 1, &ztile[axis])) ESCAPE;
    102102      gfits_delete (header, key, 1);
     
    110110  ALLOCATE (optvalue, char *, NOPTIONS);
    111111  for (Noptions = 0; TRUE; Noptions++) {
    112     snprintf (key, 10, "ZNAME%d", Noptions + 1);
     112    snprintf_nowarn (key, 10, "ZNAME%d", Noptions + 1);
    113113    if (!gfits_scan (header, key, "%s", 1, word)) break;
    114114    gfits_delete (header, key, 1);
    115115    optname[Noptions] = strcreate (word);
    116116
    117     snprintf (key, 10, "ZVAL%d", Noptions + 1);
     117    snprintf_nowarn (key, 10, "ZVAL%d", Noptions + 1);
    118118    if (!gfits_scan (header, key, "%s", 1, word)) ESCAPE;
    119119    gfits_delete (header, key, 1);
     
    204204  int colnum;
    205205  for (colnum = 1; TRUE; colnum++) {
    206     snprintf (key, 10, "TTYPE%d", colnum);
     206    snprintf_nowarn (key, 10, "TTYPE%d", colnum);
    207207    if (!gfits_scan (ftable->header, key, "%s", 1, word)) ESCAPE;
    208208    if (!strcmp (word, "COMPRESSED_DATA")) break;
     
    212212  if (!gfits_varlength_column_define (ftable, &zdef, zcol)) ESCAPE;
    213213  gfits_delete (header, "TFIELDS", 1);
    214   snprintf (key, 10, "TTYPE"OFF_T_FMT,  zcol);
     214  snprintf_nowarn (key, 10, "TTYPE"OFF_T_FMT,  zcol);
    215215  gfits_delete (header, key, 1);
    216   snprintf (key, 10, "TFORM"OFF_T_FMT,  zcol);
     216  snprintf_nowarn (key, 10, "TFORM"OFF_T_FMT,  zcol);
    217217  gfits_delete (header, key, 1);
    218218
  • trunk/Ohana/src/libohana/include/ohana.h

    r40291 r40549  
    7979  struct timeval startTimer, stopTimer; \
    8080  gettimeofday (&startTimer, (void *) NULL);
     81
     82// several snprintf statements below my truncate their output
     83// gcc (since 8.1) warns if the output may be truncated.
     84// If we do not care, the following snprintf_nowarn can
     85// replace these snprintf calls. (myNOOP in string.c)
     86
     87# define snprintf_nowarn(...) (snprintf(__VA_ARGS__) < 0 ? myNOOP() : 0)
    8188
    8289#ifdef __GNUC__
     
    314321char   *getword                PROTO((char *string));
    315322char   *skipword               PROTO((char *string));
     323void    myNOOP                 PROTO((void));
    316324
    317325/* in findexec.c */
  • trunk/Ohana/src/libohana/src/string.c

    r39407 r40549  
    11# include <ohana.h>
     2
     3// several snprintf statements below my truncate their output
     4// gcc (since 8.1) warns if the output may be truncated.
     5// the following NOOP function is used to fool the compiler
     6// see snprintf_nowarn in ohana.h
     7void myNOOP (void) { }
    28
    39/* Strip WHITESPACE from the start and end of STRING. */
  • trunk/Ohana/src/opihi/cmd.basic/module.c

    r12332 r40549  
    2323  /* search for requested file in MODULES:0 - MODULES:n */
    2424  for (i = 0; i < Nmodules; i++) {
    25     snprintf (modname, 16, "MODULES:%d", i);
     25    snprintf_nowarn (modname, 16, "MODULES:%d", i);
    2626    modpath = get_variable (modname);
    2727    if (modpath == NULL) {
  • trunk/Ohana/src/opihi/cmd.data/imspline_apply.c

    r34584 r40549  
    4747  gfits_create_matrix (&out[0].header, &out[0].matrix);
    4848  if ((y1[0].file[0] != '*') && (y1[0].file[0] != '(')) {
    49     sprintf (out[0].file, "*%s", y1[0].file);
     49    snprintf_nowarn (out[0].file, OPIHI_NAME_SIZE, "*%s", y1[0].file);
    5050  } else {
    51     sprintf (out[0].file, "%s", y1[0].file);
     51    snprintf_nowarn (out[0].file, OPIHI_NAME_SIZE, "%s", y1[0].file);
    5252  }
    5353
  • trunk/Ohana/src/opihi/cmd.data/imspline_construct.c

    r34584 r40549  
    1919  free (out[0].matrix.buffer);
    2020  if ((in[0].file[0] != '*') && (in[0].file[0] != '(')) {
    21     sprintf (out[0].file, "*%s", in[0].file);
     21    snprintf_nowarn (out[0].file, OPIHI_NAME_SIZE, "*%s", in[0].file);
    2222  } else {
    23     sprintf (out[0].file, "%s", in[0].file);
     23    snprintf_nowarn (out[0].file, OPIHI_NAME_SIZE, "%s", in[0].file);
    2424  }
    2525  out[0].bitpix = in[0].bitpix;
  • trunk/Ohana/src/opihi/dvo/dvo_host_utils.c

    r40408 r40549  
    1313  int TIME = time(NULL);
    1414  int PID = getpid();
    15   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     15  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1616
    1717  // write the dvo comment (host independent)
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r39926 r40549  
    144144
    145145  if (PARALLEL_MANUAL && MANUAL_UNIQUER) {
    146     snprintf (uniquer, 12, "%11s", MANUAL_UNIQUER);
     146    snprintf_nowarn (uniquer, 12, "%11s", MANUAL_UNIQUER);
    147147  } else {
    148     snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     148    snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    149149  }
    150150
  • trunk/Ohana/src/relphot/src/load_catalogs.c

    r39641 r40549  
    117117
    118118  if (PARALLEL_MANUAL && MANUAL_UNIQUER) {
    119     snprintf (uniquer, 12, "%11s", MANUAL_UNIQUER);
     119    snprintf_nowarn (uniquer, 12, "%11s", MANUAL_UNIQUER);
    120120  } else {
    121     snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     121    snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    122122  }
    123123
  • trunk/Ohana/src/uniphot/src/load_zpt_table.c

    r39272 r40549  
    180180      char name[9];
    181181      // snprintf (name, 9, "TS0_%04d", i);
    182       snprintf (name, 9, "S0_MJD%d", i);
     182      snprintf_nowarn (name, 9, "S0_MJD%d", i);
    183183      if (!gfits_scan (&header, name, "%lf", 1, &mjdstart)) {
    184184        fprintf (stderr, "cannot find %s in header of %s\n", name, filename);
     
    188188
    189189      // snprintf (name, 9, "TS1_%04d", i);
    190       snprintf (name, 9, "S1_MJD%d", i);
     190      snprintf_nowarn (name, 9, "S1_MJD%d", i);
    191191      if (!gfits_scan (&header, name, "%lf", 1, &mjdstop)) {
    192192        fprintf (stderr, "cannot find %s in header of %s\n", name, filename);
  • trunk/Ohana/src/uniphot/src/match_camcorr_to_images.c

    r40488 r40549  
    4444      if (image[i].tzero > camcorr->tstop[j]) continue;
    4545
    46       int seq;
     46      int seq = 0;
    4747      int photcode = image[i].photcode;
    4848
  • trunk/Ohana/src/uniphot/src/update_dvo_fiximids.c

    r38986 r40549  
    8686  int TIME = time(NULL);
    8787  int PID = getpid();
    88   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     88  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    8989
    9090  // write out the subset table of image information
  • trunk/Ohana/src/uniphot/src/update_dvo_fixstkids.c

    r38986 r40549  
    8686  int TIME = time(NULL);
    8787  int PID = getpid();
    88   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     88  snprintf_nowarn (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    8989
    9090  // write out the subset table of image information
Note: See TracChangeset for help on using the changeset viewer.