IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 31, 2023, 10:55:31 AM (4 years ago)
Author:
eugene
Message:

convert instances of strncpy to strncpy_nowarn (or memcpy in specific cases where ending 0 is not desired)

Location:
branches/eam_branches/ipp-20220316/Ohana/src/opihi
Files:
11 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.basic/memory.c

    r41341 r42343  
    2727  if (!strcasecmp (argv[1], "checkfree")) {
    2828    ohana_memcheck (1);
     29    return (TRUE);
     30  }
     31  if (!strcasecmp (argv[1], "stats")) {
     32    OhanaMemstats memstats = ohana_memstats (0);
     33    set_variable ("memory:Ntotal", memstats.Ntotal);
     34    set_variable ("memory:Nbytes", memstats.Nbytes);
     35    set_variable ("memory:Ngood",  memstats.Ngood);
     36    set_variable ("memory:Nbad",   memstats.Nbad);
    2937    return (TRUE);
    3038  }
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.basic/test/stackmath.tp

    r42342 r42343  
    11
    2 input tap.sh
     2input ../../test/tap.tp
    33
    44macro go
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/read_vectors.c

    r42082 r42343  
    385385      if (!lineStatus && VERBOSE) {
    386386        char temp[32];
    387         strncpy (temp, c0, 32);
    388         temp[31] = 0;
     387        strncpy_nowarn (temp, c0, 31);
    389388        gprint (GP_ERR, "skip line %s\n\n", temp);
    390389      }
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/test/histogram.sh

    r20936 r42343  
    3535 local i
    3636
    37  list word -x "ps -p $PID -o rss"
    38  $startmem = $word:1
     37 create xhis 0 10 0.1
     38 $i = 1
     39
     40 memory stats
     41 $startmem = $memory:Ntotal
    3942
    4043 for i 0 1000
     
    4245 end
    4346 
    44  list word -x "ps -p $PID -o rss"
    45  $endmem = $word:1
     47 memory stats
     48 $endmem = $memory:Ntotal
    4649
    4750 $PASS = 1
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/test/join.sh

    r36084 r42343  
    2121
    2222 join ID1 ID2
    23 
    24 mana: for i 0 index1[]
    25 >> echo index1[$i] index2[$i]
    26 >> end
    27 0 2
    28 2 1
    29 4 0
    30 5 3
    31 mana: join ID1 ID2 -outer
    32 mana: vectors
    33     N       name      size
    34     0        ID1          6 (INT)
    35     1       val1          6 (FLT)
    36     2        ID2          4 (INT)
    37     3        val          4 (FLT)
    38     4     index1          6 (INT)
    39     5     index2          4 (INT)
    40 mana: for i 0 index1[]
    41 >> echo index1[$i]
    42 >> end
    43 2
    44 -1
    45 1
    46 -1
    47 0
    48 3
    49 mana: echo ID1[2]
    50 3
    51 mana: echo ID1[0] ID2[2]
    52 1 1
    53 mana: for i 0 index1[]
    54 >> if (index1[$i] == -1) continue
    55 >> $N = index1[$i]
    56 >> echo $i index1[$i] ID1[$i] ID2[$N]
    57 >> end
    58 0 2 1 1
    59 2 1 3 3
    60 4 0 5 5
    61 5 3 6 6
    62 mana: for i 0 index2[]
    63 >> if (index2[$i] == -1) continue
    64 >> $N = index2[$i]
    65 >> echo $i index2[$i] ID2[$i] ID1[$N]
    66 >> end
    67 0 4 5 5
    68 1 2 3 3
    69 2 0 1 1
    70 3 5 6 6
    71 mana:
    72 
    73  # if ((xvec[1024] != 17) || (yvec[1024] != 100))
    74  #  $PASS = 0
    75  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 17,100)"
    76  # end
    77  #
    78  # imhist -q buff xvec yvec -region 40 0 25 10 -range 0 10
    79  #
    80  # if ((xvec[1024] != 10) || (yvec[1024] != 100))
    81  #  $PASS = 0
    82  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 10,100)"
    83  # end
    8423
    8524end
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/wd.c

    r41674 r42343  
    115115      Ns = strlen (simple);
    116116      No = 80 - Ns;
    117       strncpy (temp_header.buffer, simple, Ns);
     117      strncpy_nowarn (temp_header.buffer, simple, Ns);
    118118      memset (&temp_header.buffer[Ns], ' ', No);
    119119    }
     
    275275  return (f);
    276276}
    277 
    278 
    279 ///    /* fix up header */
    280 ///    {
    281 ///      static char simple[] = "XTENSION= 'IMAGE  '            / Image extension";
    282 ///      int Ns, No;
    283 ///      Ns = strlen (simple);
    284 ///      No = 80 - Ns;
    285 ///      strncpy (temp_header.buffer, simple, Ns);
    286 ///      memset (&temp_header.buffer[Ns], ' ', No);
    287 ///    }
    288 ///
    289 ///    /* position to end of file to write new extend */
    290 ///    fseeko (f, 0LL, SEEK_END);
    291 ///    nbytes = fwrite (temp_header.buffer, 1, temp_header.datasize, f);
    292 ///    fclose (f);
    293 ///    if (nbytes != temp_header.datasize) {
    294 ///      gprint (GP_ERR, "failed to write file\n");
    295 ///      status = FALSE;
    296 ///      goto done1;
    297 ///    }
    298 ///
    299 ///  }
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/write_vectors.c

    r42166 r42343  
    214214    /* identify type (%NNNNd %NNNNf) */
    215215    for (p2 = p1 + 1; (*p2 == '.') || (*p2 == '-') || (*p2 == '+') || (*p2 == ' ') || isdigit(*p2); p2++);
    216     strncpy (fmtlist[j], p0, p2 - p0 + 1);
     216    strncpy_nowarn (fmtlist[j], p0, p2 - p0 + 1);
    217217    switch (*p2) {
    218218      case 'e':
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/dvo/aregion.c

    r27435 r42343  
    4949  fread (buffer, 1, 48*NDecLines[NBigDec], f);
    5050  for (i = 0; !done && (i < NDecLines[NBigDec]); i++) {
    51     strncpy (temp, &buffer[i*48], 48);
    52     temp[49] = 0;
     51    strncpy_nowarn (temp, &buffer[i*48], 48);
    5352    hstgsc_hms_to_deg (&RA0, &RA1, &DEC0, &DEC1, &temp[7]);
    5453    if (RA1 < RA0) RA1 += 360.0;
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/dvo/find_regions.c

    r27435 r42343  
    100100    fread (buffer, 48*NDecLines[NBigDec + j], 1, f);
    101101    for (i = 0; (i < NDecLines[NBigDec + j]); i++) {
    102       strncpy (temp, &buffer[i*48], 48);
    103       temp[49] = 0;
     102      strncpy_nowarn (temp, &buffer[i*48], 48);
    104103      hstgsc_hms_to_deg (&RA0, &RA1, &DEC0, &DEC1, &temp[7]);
    105104      if (RA1 < RA0) RA1 += 360.0;
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/VectorIO.c

    r42166 r42343  
    261261  memset (endptr, ' ', FT_LINE_LENGTH);
    262262
    263   strncpy (endptr, newline, 80);
     263  strncpy_nowarn (endptr, newline, 80);
    264264  endptr += FT_LINE_LENGTH;
    265265
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/expand_vectors.c

    r42165 r42343  
    5151
    5252  n = L - line;
    53   strncpy (newline, line, n);
     53  strncpy_nowarn (newline, line, n);
    5454  N = newline + n;
    5555  J = 0;
     
    256256
    257257    n = (int) (w - L);
    258     strncpy (N, L, n);
     258    strncpy_nowarn (N, L, n);
    259259    N += n;
    260260    n = strlen (strValue);
    261     strncpy (N, strValue, n);
     261    strncpy_nowarn (N, strValue, n);
    262262    N += n;
    263263    L = q + 1;
     
    274274
    275275  n = strlen (L);
    276   strncpy (N, L, n);
    277   N[n] = 0;
     276  strncpy_nowarn (N, L, n);
    278277  free (line);
    279278  return (newline);
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/test/tests.sh

    r41470 r42343  
    5353  for Tj 0 $testscripts:n
    5454    if ($VERBOSE > 1)
    55       echo " running $testscripts:$Tj"
     55      echo " ----- running $testscripts:$Tj -----"
    5656    end
    5757    runtests $testscripts:$Tj     
Note: See TracChangeset for help on using the changeset viewer.