Changeset 691

Show
Ignore:
Timestamp:
12/29/09 09:07:41 (2 years ago)
Author:
erikd
Message:

Remove needless #defines of buffer lengths.

Code had many instances of:

#undef BUF_LEN
#define BUF_LEN 64
char buf[BUF_LEN];
snprintf (buf, BUF_LEN, ....);

which can be replaced with:

char buf[64];
snprintf (buf, sizeof (buf), ....);

which is far cleaner and more difficult to get wrong.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/trunk/plugins/ladspa/ladspameta.c

    r688 r691  
    653653ladspa_meta_add_procs (gchar * dir, gchar * name) 
    654654{ 
    655 #define PATH_LEN 256 
    656   gchar path[PATH_LEN]; 
     655  gchar path[256]; 
    657656  void * module; 
    658657  LADSPA_Descriptor_Function desc_func; 
     
    663662  sw_procedure * proc; 
    664663 
    665   snprintf (path, PATH_LEN, "%s/%s", dir, name); 
     664  snprintf (path, sizeof (path), "%s/%s", dir, name); 
    666665 
    667666  module = dlopen (path, RTLD_NOW); 
  • sweep/trunk/src/about_dialog.c

    r688 r691  
    5757  GtkWidget *vbox; 
    5858  GtkWidget *label; 
    59 #define BUF_LEN 64 
    60   gchar buf[BUF_LEN]; 
     59  gchar buf[64]; 
    6160  GtkWidget * button; 
    6261  GtkWidget * about_image; 
     
    9897  *  gtk_widget_push_style(style); 
    9998  */ 
    100     snprintf (buf, BUF_LEN, "%s %s", _("This is Sweep version"), VERSION); 
     99    snprintf (buf, sizeof (buf), "%s %s", _("This is Sweep version"), VERSION); 
    101100    label = gtk_label_new(buf); 
    102101    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); 
  • sweep/trunk/src/channelops.c

    r688 r691  
    139139dup_channels (sw_sample * sample, int new_channels) 
    140140{ 
    141 #undef BUF_LEN 
    142 #define BUF_LEN 128 
    143   char buf[BUF_LEN]; 
     141  char buf[128]; 
    144142 
    145143  if (sample->sounddata->format->channels == 1) { 
    146     g_snprintf (buf, BUF_LEN, _("Duplicate to %d channels"), new_channels); 
     144    g_snprintf (buf, sizeof (buf), _("Duplicate to %d channels"), new_channels); 
    147145  } else { 
    148     g_snprintf (buf, BUF_LEN, _("Duplicate from %d to %d channels"), 
     146    g_snprintf (buf, sizeof (buf), _("Duplicate from %d to %d channels"), 
    149147                sample->sounddata->format->channels, new_channels); 
    150148  } 
     
    629627change_channels (sw_sample * sample, int new_channels) 
    630628{ 
    631 #undef BUF_LEN 
    632 #define BUF_LEN 128 
    633   char buf[BUF_LEN]; 
    634  
    635   g_snprintf (buf, BUF_LEN, _("Convert from %d to %d channels"), 
     629  char buf[128]; 
     630 
     631  g_snprintf (buf, sizeof (buf), _("Convert from %d to %d channels"), 
    636632              sample->sounddata->format->channels, new_channels); 
    637633  
  • sweep/trunk/src/db_ruler.c

    r688 r691  
    341341  gfloat subd_incr; 
    342342  gfloat start, end, cur; 
    343 #define UNIT_STR_LEN 32 
    344   gchar unit_str[UNIT_STR_LEN]; 
     343  gchar unit_str[32]; 
    345344  gint digit_height; 
    346345  gint digit_offset; 
     
    468467             
    469468            if (db_cur > -10.0) { 
    470               snprintf (unit_str, UNIT_STR_LEN, "%1.1f", db_cur); 
     469              snprintf (unit_str, sizeof (unit_str), "%1.1f", db_cur); 
    471470            } else { 
    472               snprintf (unit_str, UNIT_STR_LEN, "%2.0f", db_cur); 
     471              snprintf (unit_str, sizeof (unit_str), "%2.0f", db_cur); 
    473472            } 
    474473           
  • sweep/trunk/src/file_dialogs.c

    r688 r691  
    143143{ 
    144144  struct stat statbuf; 
    145  
    146 #undef BUF_LEN 
    147 #define BUF_LEN 512 
    148   char buf[BUF_LEN]; 
     145  char buf[512]; 
    149146 
    150147  gchar * dirname; 
     
    155152    switch (errno) { 
    156153    case ENOENT: 
    157       snprintf (buf, BUF_LEN, _("%s does not exist."), dirname); 
     154      snprintf (buf, sizeof (buf), _("%s does not exist."), dirname); 
    158155      info_dialog_new (_("Directory does not exist"), NULL, buf); 
    159156      g_free (dirname); 
     
    361358  sw_view * view = (sw_view *)data; 
    362359  sw_sample * sample; 
    363 #undef BUF_LEN 
    364 #define BUF_LEN 512 
    365   char buf[BUF_LEN]; 
     360  char buf[512]; 
    366361     
    367362  sample = view->sample; 
    368363 
    369   snprintf (buf, BUF_LEN
     364  snprintf (buf, sizeof (buf)
    370365            _("Are you sure you want to revert %s to\n%s?\n\n" 
    371366              "All changes and undo information will be lost."), 
     
    692687  save_as_data * sd; 
    693688 
    694 #undef BUF_LEN 
    695 #define BUF_LEN 512 
    696   char buf[BUF_LEN]; 
    697  
     689  char buf[512]; 
    698690  char * last_save; 
    699691 
     
    808800        sweep_perror (errno, _("You are not allowed to write to\n%s"), filename); 
    809801      } else { 
    810         snprintf (buf, BUF_LEN, _("%s exists. Overwrite?"), filename); 
     802        snprintf (buf, sizeof (buf), _("%s exists. Overwrite?"), filename); 
    811803 
    812804        question_dialog_new (sample, _("File exists"), buf, 
     
    868860  sw_view * view = (sw_view *)data; 
    869861  sw_sample * sample; 
    870 #undef BUF_LEN 
    871 #define BUF_LEN 512 
    872   char buf[BUF_LEN]; 
     862  char buf[512]; 
    873863     
    874864  sample = view->sample; 
     
    878868    sample_save_as_cb (widget, data); 
    879869  } else if (sample_mtime_changed (sample)) { 
    880     snprintf (buf, BUF_LEN
     870    snprintf (buf, sizeof (buf)
    881871              _("%s\n has changed on disk.\n\n" 
    882872                "Are you sure you want to save?"), 
  • sweep/trunk/src/file_mad.c

    r688 r691  
    8787 * reimplement this check as a contextual verfification of  
    8888 * a sequence of frames, starting from somewhere in the middle 
    89  * of a file. in the mean time, raise BUF_LEN from 2048 to 8192 
     89 * of a file. in the mean time, raise size of buf from 2048 to 8192 
    9090 * to mitigate the chance of a false negative. (with an increased  
    9191 * change of a false positive as a result.) 
    9292 */ 
    93 #define BUF_LEN 8192  
    94   unsigned char buf[BUF_LEN]; 
     93  unsigned char buf[8192]; 
    9594  int n, i; 
    9695 
     
    9897  if (fd == -1) goto out_false; 
    9998 
    100   n = read (fd, buf, BUF_LEN); 
     99  n = read (fd, buf, sizeof (buf)); 
    101100  if (n < 4) goto out_false; 
    102101 
    103102  /* Check for MPEG frame marker */ 
    104   for (i = 0; i < BUF_LEN-1; i++) { 
     103  for (i = 0; i < sizeof (buf)-1; i++) { 
    105104    if ((buf[i] & 0xff) == 0xff && (buf[i+1] & 0xe0) == 0xe0) { 
    106105      goto out_true; 
     
    378377sample_load_mad_info (sw_sample * sample, char * pathname) 
    379378{ 
    380 #undef BUF_LEN 
    381 #define BUF_LEN 128 
    382   char buf[BUF_LEN]; 
     379  char buf[128]; 
    383380 
    384381  gboolean isnew = (sample == NULL); 
     
    427424  } 
    428425 
    429   g_snprintf (buf, BUF_LEN, _("Loading %s"), g_basename (sample->pathname)); 
     426  g_snprintf (buf, sizeof (buf), _("Loading %s"), g_basename (sample->pathname)); 
    430427 
    431428  schedule_operation (sample, buf, &mad_load_op, sample); 
  • sweep/trunk/src/file_sndfile1.c

    r688 r691  
    5353#include "view.h" 
    5454 
    55 #define BUF_LEN 128 
    56  
    5755extern GtkStyle * style_wb; 
    5856 
     
    7876sweep_sndfile_perror (SNDFILE * sndfile, gchar * pathname) 
    7977{ 
    80 #undef BUF_LEN 
    81 #define BUF_LEN 128 
    82   char buf[BUF_LEN]; 
    83  
    84   sf_error_str (sndfile, buf, BUF_LEN); 
     78  char buf[128]; 
     79 
     80  sf_error_str (sndfile, buf, sizeof (buf)); 
    8581 
    8682  sweep_perror (errno, "libsndfile: %s\n\n%s", buf, 
     
    623619{ 
    624620  SNDFILE * sndfile; 
    625 #undef BUF_LEN 
    626 #define BUF_LEN 128 
    627   char buf[BUF_LEN]; 
     621  char buf[128]; 
    628622  gchar * message; 
    629623 
     
    653647    } 
    654648 
    655     sf_error_str (NULL, buf, BUF_LEN); 
    656     if (!strncmp (buf, RAW_ERR_STR_1, BUF_LEN) || 
    657         !strncmp (buf, RAW_ERR_STR_2, BUF_LEN)) { 
     649    sf_error_str (NULL, buf, sizeof (buf)); 
     650    if (!strncmp (buf, RAW_ERR_STR_1, sizeof (buf)) || 
     651        !strncmp (buf, RAW_ERR_STR_2, sizeof (buf))) { 
    658652 
    659653      so = g_malloc0 (sizeof(*so)); 
     
    722716  } 
    723717 
    724   g_snprintf (buf, BUF_LEN, _("Loading %s"), g_basename (sample->pathname)); 
     718  g_snprintf (buf, sizeof (buf), _("Loading %s"), g_basename (sample->pathname)); 
    725719 
    726720  sf = g_malloc0 (sizeof(sf_data)); 
     
    947941sndfile_sample_save (sw_sample * sample, gchar * pathname) 
    948942{ 
    949   char buf[BUF_LEN]; 
    950  
    951   g_snprintf (buf, BUF_LEN, _("Saving %s"), g_basename (pathname)); 
     943  char buf[128]; 
     944 
     945  g_snprintf (buf, sizeof (buf), _("Saving %s"), g_basename (pathname)); 
    952946 
    953947  schedule_operation (sample, buf, &sndfile_save_op, g_strdup (pathname)); 
  • sweep/trunk/src/file_speex.c

    r688 r691  
    8383#endif 
    8484 
    85 #define BUFFER_LEN 1024 
    86  
    8785#include <glib.h> 
    8886#include <gdk/gdkkeysyms.h> 
     
    120118#define HAVE_SPEEX_BETA4 
    121119#endif 
    122  
    123 #define BUF_LEN 128 
    124120 
    125121#define MODE_KEY "Speex_Mode" 
     
    527523sample_load_speex_info (sw_sample * sample, char * pathname) 
    528524{ 
    529 #undef BUF_LEN 
    530 #define BUF_LEN 128 
    531   char buf[BUF_LEN]; 
     525  char buf[128]; 
    532526 
    533527  gboolean isnew = (sample == NULL); 
     
    575569  } 
    576570 
    577   g_snprintf (buf, BUF_LEN, _("Loading %s"), g_basename (sample->pathname)); 
     571  g_snprintf (buf, sizeof (buf), _("Loading %s"), g_basename (sample->pathname)); 
    578572 
    579573  schedule_operation (sample, buf, &speex_load_op, sample); 
     
    958952  /* Report success or failure; Calculate and display statistics */ 
    959953 
    960 #undef BUF_LEN 
    961 #define BUF_LEN 16 
    962  
    963954  if (remaining <= 0) { 
    964     char time_buf[BUF_LEN], bytes_buf[BUF_LEN]; 
     955    char time_buf[16], bytes_buf[16]; 
    965956 
    966957    sample_store_and_free_pathname (sample, pathname); 
     
    973964    sample->modified = FALSE; 
    974965 
    975     snprint_time (time_buf, BUF_LEN
     966    snprint_time (time_buf, sizeof (time_buf)
    976967                  frames_to_time (format, nr_frames - remaining)); 
    977968 
    978     snprint_bytes (bytes_buf, BUF_LEN, bytes_written); 
     969    snprint_bytes (bytes_buf, sizeof (bytes_buf), bytes_written); 
    979970 
    980971    average_bitrate = 
     
    989980                     average_bitrate); 
    990981  } else { 
    991     char time_buf[BUF_LEN], bytes_buf[BUF_LEN]; 
    992  
    993     snprint_time (time_buf, BUF_LEN
     982    char time_buf[16], bytes_buf[16]; 
     983 
     984    snprint_time (time_buf, sizeof (time_buf)
    994985                  frames_to_time (format, nr_frames - remaining)); 
    995986 
    996     snprint_bytes (bytes_buf, BUF_LEN, bytes_written); 
     987    snprint_bytes (bytes_buf, sizeof (bytes_buf), bytes_written); 
    997988 
    998989    average_bitrate = 
     
    10351026speex_sample_save (sw_sample * sample, char * pathname) 
    10361027{ 
    1037 #undef BUF_LEN 
    1038 #define BUF_LEN 64 
    1039   char buf[BUF_LEN]; 
    1040  
    1041   g_snprintf (buf, BUF_LEN, _("Saving %s"), g_basename (pathname)); 
     1028  char buf[64]; 
     1029 
     1030  g_snprintf (buf, sizeof (buf), _("Saving %s"), g_basename (pathname)); 
    10421031 
    10431032  schedule_operation (sample, buf, &speex_save_op, pathname); 
  • sweep/trunk/src/file_vorbis.c

    r688 r691  
    7878#include <vorbis/vorbisenc.h> 
    7979 
    80 #define BUFFER_LEN 1024 
    81  
    8280#include <glib.h> 
    8381#include <gdk/gdkkeysyms.h> 
     
    103101#include "../pixmaps/vorbisword2.xpm" 
    104102#include "../pixmaps/xifish.xpm" 
    105  
    106 #define BUF_LEN 128 
    107103 
    108104#define QUALITY_KEY "OggVorbis_Quality" 
     
    251247  int ret; 
    252248 
    253 #undef BUF_LEN 
    254 #define BUF_LEN 128 
    255   char buf[BUF_LEN]; 
     249  char buf[128]; 
    256250 
    257251  gboolean isnew = (sample == NULL); 
     
    322316  } 
    323317 
    324   g_snprintf (buf, BUF_LEN, _("Loading %s"), g_basename (sample->pathname)); 
     318  g_snprintf (buf, sizeof (buf), _("Loading %s"), g_basename (sample->pathname)); 
    325319 
    326320#ifdef DEVEL_CODE 
     
    331325    sw_metadata * metadata = NULL; 
    332326 
    333 #undef BUF_LEN 
    334 #define BUF_LEN 1024 
    335     char buf[BUF_LEN]; 
     327    char buf[1024]; 
    336328    int n = 0; 
    337329 
     
    346338          metadata_list = g_list_append (metadata_list, metadata); 
    347339 
    348         n += snprintf (buf+n, BUF_LEN-n, "%s: %s\n", 
     340        n += snprintf (buf+n, sizeof (buf)-n, "%s: %s\n", 
    349341                       metadata->name, metadata->content); 
    350342      } 
     
    614606  /* Report success or failure; Calculate and display statistics */ 
    615607 
    616 #undef BUF_LEN 
    617 #define BUF_LEN 16 
    618  
    619608  if (remaining <= 0) { 
    620     char time_buf[BUF_LEN], bytes_buf[BUF_LEN]; 
     609    char time_buf[16], bytes_buf[16]; 
    621610 
    622611    sample_store_and_free_pathname (sample, pathname); 
     
    629618    sample->modified = FALSE; 
    630619 
    631     snprint_time (time_buf, BUF_LEN
     620    snprint_time (time_buf, sizeof (time_buf)
    632621                  frames_to_time (format, nr_frames - remaining)); 
    633622 
    634     snprint_bytes (bytes_buf, BUF_LEN, bytes_written); 
     623    snprint_bytes (bytes_buf, sizeof (bytes_buf), bytes_written); 
    635624 
    636625    average_bitrate = 
     
    645634                     average_bitrate); 
    646635  } else { 
    647     char time_buf[BUF_LEN], bytes_buf[BUF_LEN]; 
    648  
    649     snprint_time (time_buf, BUF_LEN
     636    char time_buf[16], bytes_buf[16]; 
     637 
     638    snprint_time (time_buf, sizeof (time_buf)
    650639                  frames_to_time (format, nr_frames - remaining)); 
    651640 
    652     snprint_bytes (bytes_buf, BUF_LEN, bytes_written); 
     641    snprint_bytes (bytes_buf, sizeof (bytes_buf), bytes_written); 
    653642 
    654643    average_bitrate = 
     
    692681vorbis_sample_save (sw_sample * sample, char * pathname) 
    693682{ 
    694 #undef BUF_LEN 
    695 #define BUF_LEN 64 
    696   char buf[BUF_LEN]; 
    697  
    698   g_snprintf (buf, BUF_LEN, _("Saving %s"), g_basename (pathname)); 
     683  char buf[64]; 
     684 
     685  g_snprintf (buf, sizeof (buf), _("Saving %s"), g_basename (pathname)); 
    699686 
    700687  schedule_operation (sample, buf, &vorbis_save_op, pathname); 
  • sweep/trunk/src/head.c

    r688 r691  
    234234  sw_framecount_t offset = head->offset; 
    235235 
    236 #define BUF_LEN 16 
    237   char buf[BUF_LEN]; 
    238  
    239   snprint_time (buf, BUF_LEN, 
     236  char buf[16]; 
     237 
     238  snprint_time (buf, sizeof (buf), 
    240239                frames_to_time (sample->sounddata->format, offset)); 
    241240 
  • sweep/trunk/src/param.c

    r690 r691  
    135135print_param (sw_param_type type, sw_param p) 
    136136{ 
    137 #define BUF_LEN 64 
    138   gchar buf[BUF_LEN]; 
    139  
    140   snprint_param (buf, BUF_LEN, type, p); 
     137  gchar buf[64]; 
     138 
     139  snprint_param (buf, sizeof (buf), type, p); 
    141140  printf ("%s", buf); 
    142 #undef BUF_LEN 
    143141} 
    144142 
     
    363361  int valid=0; 
    364362 
    365 #define BUF_LEN 64 
    366   gchar buf[BUF_LEN]; 
     363  gchar buf[64]; 
    367364 
    368365  GtkWidget * table; 
     
    433430          plsk[j].p2 = &pspec->constraint.list[j+1]; 
    434431 
    435           snprint_param (buf, BUF_LEN, pspec->type, 
     432          snprint_param (buf, sizeof (buf), pspec->type, 
    436433                         pspec->constraint.list[j+1]); 
    437434 
     
    527524 
    528525  return table; 
    529  
    530 #undef BUF_LEN 
    531526} 
    532527 
     
    581576  GtkWidget * text; 
    582577 
    583 #define BUF_LEN 1024 
    584   gchar buf[BUF_LEN]; 
     578  gchar buf[1024]; 
    585579  gint n; 
    586580 
     
    648642 * gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); 
    649643 * 
    650  * n = snprintf (buf, BUF_LEN, "%s\n\n", _(proc->name)); 
     644 * n = snprintf (buf, sizeof (buf), "%s\n\n", _(proc->name)); 
    651645 * gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buf, n); 
    652646 */ 
  • sweep/trunk/src/paste_dialogs.c

    r688 r691  
    168168 
    169169  sw_time_t duration; 
    170  
    171 #undef BUF_LEN 
    172 #define BUF_LEN 16 
    173   char buf[BUF_LEN]; 
     170  char buf[16]; 
    174171 
    175172  if (xfade) { 
     
    315312 
    316313  duration = frames_to_time (sample->sounddata->format, clipboard_width ()); 
    317   snprint_time (buf, BUF_LEN, duration); 
     314  snprint_time (buf, sizeof (buf), duration); 
    318315 
    319316  label = gtk_label_new (buf); 
  • sweep/trunk/src/question_dialogs.c

    r557 r691  
    216216  info_dialog_data * id; 
    217217  va_list ap; 
    218 #define BUF_LEN 512 
    219   char buf[BUF_LEN]; 
     218  char buf[512]; 
    220219 
    221220  va_start (ap, fmt); 
    222   vsnprintf (buf, BUF_LEN, fmt, ap); 
     221  vsnprintf (buf, sizeof (buf), fmt, ap); 
    223222  va_end (ap); 
    224223 
     
    266265  sweep_perror_data * pd; 
    267266  va_list ap; 
    268 #undef BUF_LEN 
    269 #define BUF_LEN 512 
    270   char buf[BUF_LEN]; 
     267  char buf[512]; 
    271268 
    272269  va_start (ap, fmt); 
    273   vsnprintf (buf, BUF_LEN, fmt, ap); 
     270  vsnprintf (buf, sizeof (buf), fmt, ap); 
    274271  va_end (ap); 
    275272 
  • sweep/trunk/src/samplerate.c

    r587 r691  
    8181  int channel = 0; 
    8282 
    83   /*  float input[BUFFER_LEN], output[BUFFER_LEN];*/ 
    8483  SRC_STATE * src_state; 
    8584  SRC_DATA src_data; 
     
    227226{ 
    228227  src_options * so; 
    229  
    230 #undef BUF_LEN 
    231 #define BUF_LEN 128 
    232   char buf[BUF_LEN]; 
    233  
    234   g_snprintf (buf, BUF_LEN, _("Resample from %d Hz to %d Hz"), 
     228  char buf[128]; 
     229 
     230  g_snprintf (buf, sizeof (buf), _("Resample from %d Hz to %d Hz"), 
    235231              sample->sounddata->format->rate, new_rate); 
    236232 
  • sweep/trunk/src/sw_chooser.c

    r271 r691  
    146146{ 
    147147  GtkWidget * direct_entry; 
    148 #define BUF_LEN 16 
    149   char buf[BUF_LEN]; 
     148  char buf[16]; 
    150149 
    151150  direct_entry = 
     
    157156   */ 
    158157  if (number > 0) { 
    159     snprintf (buf, BUF_LEN, "%d", number); 
     158    snprintf (buf, sizeof (buf), "%d", number); 
    160159  } else { 
    161160    buf[0] = '\0'; 
  • sweep/trunk/src/sweep_sample.c

    r688 r691  
    288288  glong bytes; 
    289289 
    290 #undef BUF_LEN 
    291 #define BUF_LEN 16 
    292   char buf[BUF_LEN]; 
     290  char buf[16]; 
    293291 
    294292  dialog = gtk_widget_get_toplevel (widget); 
     
    310308    gtk_label_set_text (GTK_LABEL(memsize_label), _("Overflow")); 
    311309  } else { 
    312     snprint_bytes (buf, BUF_LEN, bytes); 
     310    snprint_bytes (buf, sizeof (buf), bytes); 
    313311    gtk_label_set_text (GTK_LABEL(memsize_label), buf); 
    314312  } 
     
    385383  GtkTooltips * tooltips; 
    386384 
    387 #define BUF_LEN 16 
    388   gchar buf[BUF_LEN]; 
     385  gchar buf[16]; 
    389386 
    390387  dialog = gtk_dialog_new (); 
     
    447444  gtk_widget_show (entry); 
    448445 
    449   snprint_time (buf, BUF_LEN, duration); 
     446  snprint_time (buf, sizeof (buf), duration); 
    450447  gtk_entry_set_text (GTK_ENTRY (entry), buf);  
    451448 
     
    608605 
    609606  gtk_widget_show (dialog); 
    610  
    611 #undef BUF_LEN 
    612607} 
    613608 
     
    12181213{ 
    12191214  va_list ap; 
    1220 #undef BUF_LEN 
    1221 #define BUF_LEN 512 
    1222   char buf[BUF_LEN]; 
     1215  char buf[512]; 
    12231216 
    12241217  va_start (ap, fmt); 
    1225   vsnprintf (buf, BUF_LEN, fmt, ap); 
     1218  vsnprintf (buf, sizeof (buf), fmt, ap); 
    12261219  va_end (ap); 
    12271220 
     
    16051598{ 
    16061599  int n; 
    1607 #undef BUF_LEN 
    1608 #define BUF_LEN 64 
    1609   gchar buf[BUF_LEN]; 
     1600  gchar buf[64]; 
    16101601  sw_format * format = s->sounddata->format; 
    16111602  sw_sel * sel; 
    16121603 
    1613   n = snprintf (buf, BUF_LEN, _("Insert selection [")); 
    1614   n += snprint_time (buf+n, BUF_LEN-n, 
     1604  n = snprintf (buf, sizeof (buf), _("Insert selection [")); 
     1605  n += snprint_time (buf+n, sizeof (buf)-n, 
    16151606                     frames_to_time (format, s->tmp_sel->sel_start)); 
    1616   n += snprintf (buf+n, BUF_LEN-n, " - "); 
    1617   n += snprint_time (buf+n, BUF_LEN-n, 
     1607  n += snprintf (buf+n, sizeof (buf)-n, " - "); 
     1608  n += snprint_time (buf+n, sizeof (buf)-n, 
    16181609                     frames_to_time (format, s->tmp_sel->sel_end)); 
    1619   n += snprintf (buf+n, BUF_LEN-n, "]"); 
     1610  n += snprintf (buf+n, sizeof (buf)-n, "]"); 
    16201611 
    16211612  g_mutex_lock (s->sounddata->sels_mutex); 
     
    16291620   
    16301621  perform_selection_op (s, buf, ssits, NULL, sel); 
    1631 #undef BUF_LEN 
    16321622} 
    16331623 
     
    16591649{ 
    16601650  int n; 
    1661 #define BUF_LEN 64 
    1662   gchar buf[BUF_LEN]; 
     1651  gchar buf[64]; 
    16631652  sw_format * format = s->sounddata->format; 
    16641653  sw_sel * sel; 
    16651654 
    1666   n = snprintf (buf, BUF_LEN, _("Subtract selection [")); 
    1667   n += snprint_time (buf+n, BUF_LEN-n, 
     1655  n = snprintf (buf, sizeof (buf), _("Subtract selection [")); 
     1656  n += snprint_time (buf+n, sizeof (buf)-n, 
    16681657                     frames_to_time (format, s->tmp_sel->sel_start)); 
    1669   n += snprintf (buf+n, BUF_LEN-n, " - "); 
    1670   n += snprint_time (buf+n, BUF_LEN-n, 
     1658  n += snprintf (buf+n, sizeof (buf)-n, " - "); 
     1659  n += snprint_time (buf+n, sizeof (buf)-n, 
    16711660                     frames_to_time (format, s->tmp_sel->sel_end)); 
    1672   n += snprintf (buf+n, BUF_LEN-n, "]"); 
     1661  n += snprintf (buf+n, sizeof (buf)-n, "]"); 
    16731662 
    16741663  g_mutex_lock (s->sounddata->sels_mutex); 
     
    17041693{ 
    17051694  int n; 
    1706 #define BUF_LEN 64 
    1707   gchar buf[BUF_LEN]; 
     1695  gchar buf[64]; 
    17081696  sw_format * format = s->sounddata->format; 
    17091697  sw_sel * sel; 
    17101698 
    1711   n = snprintf (buf, BUF_LEN, _("Set selection [")); 
    1712   n += snprint_time (buf+n, BUF_LEN-n, 
     1699  n = snprintf (buf, sizeof (buf), _("Set selection [")); 
     1700  n += snprint_time (buf+n, sizeof (buf)-n, 
    17131701                     frames_to_time (format, s->tmp_sel->sel_start)); 
    1714   n += snprintf (buf+n, BUF_LEN-n, " - "); 
    1715   n += snprint_time (buf+n, BUF_LEN-n, 
     1702  n += snprintf (buf+n, sizeof (buf)-n, " - "); 
     1703  n += snprint_time (buf+n, sizeof (buf)-n, 
    17161704                     frames_to_time (format, s->tmp_sel->sel_end)); 
    1717   n += snprintf (buf+n, BUF_LEN-n, "]"); 
     1705  n += snprintf (buf+n, sizeof (buf)-n, "]"); 
    17181706 
    17191707  g_mutex_lock (s->sounddata->sels_mutex); 
     
    17381726  GtkWidget * clist = sample->info_clist; 
    17391727 
    1740 #define RATE_BUF_LEN 16 
    1741   char rate_buf[RATE_BUF_LEN]; 
    1742  
    1743 #define CHAN_BUF_LEN 16 
    1744   char chan_buf[CHAN_BUF_LEN]; 
    1745  
    1746 #define BYTE_BUF_LEN 16 
    1747   char byte_buf[BYTE_BUF_LEN]; 
    1748  
    1749 #define TIME_BUF_LEN 16 
    1750   char time_buf[TIME_BUF_LEN]; 
     1728  char rate_buf[16]; 
     1729  char chan_buf[16]; 
     1730  char byte_buf[16]; 
     1731  char time_buf[16]; 
    17511732 
    17521733  if (clist == NULL) return; 
    17531734 
    1754   snprintf (rate_buf, RATE_BUF_LEN, "%d Hz", sounddata->format->rate); 
    1755  
    1756   snprintf (chan_buf, CHAN_BUF_LEN, "%d", sounddata->format->channels); 
    1757  
    1758   snprint_bytes (byte_buf, BYTE_BUF_LEN
     1735  snprintf (rate_buf, sizeof (rate_buf), "%d Hz", sounddata->format->rate); 
     1736 
     1737  snprintf (chan_buf, sizeof (chan_buf), "%d", sounddata->format->channels); 
     1738 
     1739  snprint_bytes (byte_buf, sizeof (byte_buf)
    17591740                 frames_to_bytes (sounddata->format, sounddata->nr_frames)); 
    17601741   
    1761   snprint_time (time_buf, TIME_BUF_LEN
     1742  snprint_time (time_buf, sizeof (time_buf)
    17621743                frames_to_time (sounddata->format, sounddata->nr_frames)); 
    17631744 
  • sweep/trunk/src/sweep_undo.c

    r688 r691  
    152152  sw_sample * sample = inst->sample; 
    153153 
    154 #define BUF_LEN 128 
    155   gchar buf[BUF_LEN]; 
    156  
    157   g_snprintf (buf, BUF_LEN, "%s (%%p%%%%)", inst->description); 
     154  gchar buf[128]; 
     155 
     156  g_snprintf (buf, sizeof (buf), "%s (%%p%%%%)", inst->description); 
    158157  sample_set_progress_text (sample, buf); 
    159158   
     
    164163    pthread_create (&sample->ops_thread, NULL, (void *) (*op_main), sample); 
    165164  } 
    166 #undef BUF_LEN 
    167165} 
    168166 
     
    303301{ 
    304302  sw_op_instance * inst; 
    305 #undef BUF_LEN 
    306 #define BUF_LEN 512 
    307   char buf[BUF_LEN]; 
     303  char buf[512]; 
    308304 
    309305  inst = sw_op_instance_new (sample, description, operation); 
     
    313309      !sample->edit_ignore_mtime && sample_mtime_changed (sample)) { 
    314310 
    315     snprintf (buf, BUF_LEN
     311    snprintf (buf, sizeof (buf)
    316312              _("%s\n has changed on disk.\n\n" 
    317313                "Do you want to continue editing this buffer?"), 
     
    444440{ 
    445441  sw_operation * op; 
    446 #undef BUF_LEN 
    447 #define BUF_LEN 128 
    448   gchar buf[BUF_LEN]; 
    449  
    450   g_snprintf (buf, BUF_LEN, "Undo %s", inst->description); 
     442  gchar buf[128]; 
     443 
     444  g_snprintf (buf, sizeof (buf), "Undo %s", inst->description); 
    451445 
    452446  if (inst->op->edit_mode == SWEEP_EDIT_MODE_FILTER) 
     
    525519{ 
    526520  sw_operation * op; 
    527  
    528 #define BUF_LEN 128 
    529   gchar buf[BUF_LEN]; 
    530  
    531   g_snprintf (buf, BUF_LEN, "Redo %s", inst->description); 
     521  gchar buf[128]; 
     522 
     523  g_snprintf (buf, sizeof (buf), "Redo %s", inst->description); 
    532524 
    533525  if (inst->op->edit_mode == SWEEP_EDIT_MODE_FILTER) 
  • sweep/trunk/src/time_ruler.c

    r688 r691  
    184184  gdouble subd_incr; 
    185185  gdouble start, end, cur; 
    186 #define UNIT_STR_LEN 32 
    187   gchar unit_str[UNIT_STR_LEN]; 
     186  gchar unit_str[32]; 
    188187  gint digit_height; 
    189188  gint digit_offset; 
     
    245244   */ 
    246245  scale = ceil (ruler->max_size / TIME_RULER(ruler)->samplerate); 
    247   snprint_time (unit_str, UNIT_STR_LEN, (sw_time_t)scale); 
    248   /*  snprint_time_smpte (unit_str, UNIT_STR_LEN, (sw_time_t)scale, 10.0);*/ 
     246  snprint_time (unit_str, sizeof (unit_str), (sw_time_t)scale); 
    249247 
    250248 text_width = strlen (unit_str) * digit_height + 1; 
     
    296294          if (i == 0) 
    297295            { 
    298               snprint_time (unit_str, UNIT_STR_LEN, (sw_time_t)cur); 
     296              snprint_time (unit_str, sizeof (unit_str), (sw_time_t)cur); 
    299297                  pango_layout_set_text (layout, unit_str, -1); 
    300298                  pango_layout_get_extents (layout, NULL, &logical_rect); 
  • sweep/trunk/src/view.c

    r688 r691  
    13961396view_set_pos_indicator_cb (GtkWidget * widget, gpointer data) 
    13971397{ 
     1398  char buf[16]; 
    13981399  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    13991400  sw_view * view = sd->view; 
    14001401 
    1401 #define BUF_LEN 16 
    1402   char buf[BUF_LEN]; 
    1403  
    14041402  if (sd->mouse_offset >= 0) { 
    1405     snprint_time (buf, BUF_LEN
     1403    snprint_time (buf, sizeof (buf)
    14061404                  frames_to_time (view->sample->sounddata->format, 
    14071405                                  sd->mouse_offset)); 
     
    14101408    gtk_label_set_text (GTK_LABEL(view->pos), NO_TIME); 
    14111409  } 
    1412  
    1413  
    1414 #undef BUF_LEN 
    14151410} 
    14161411 
     
    25952590  sw_framecount_t orig_length; 
    25962591  sw_time_t length; 
    2597 #define BUF_LEN 16 
    2598   gchar buf[BUF_LEN]; 
     2592  gchar buf[16]; 
    25992593  gfloat step; 
    26002594 
     
    26112605  /* Update duration displayed in zoom combo */ 
    26122606  length = frames_to_time (view->sample->sounddata->format, end-start); 
    2613   snprint_time (buf, BUF_LEN, length); 
     2607  snprint_time (buf, sizeof (buf), length); 
    26142608 
    26152609  entry = GTK_COMBO(view->zoom_combo)->entry; 
     
    26432637  view_refresh_title(view); 
    26442638  view_refresh_display(view); 
    2645  
    2646 #undef BUF_LEN 
    26472639} 
    26482640 
     
    30973089  sw_framecount_t offset; 
    30983090  static int rate_limit = 0; 
    3099  
    3100  
    3101 #define BUF_LEN 16 
    3102   char buf[BUF_LEN]; 
     3091  char buf[16]; 
    31033092 
    31043093  offset = (sample->play_head->going ? 
     
    31063095            sample->user_offset); 
    31073096 
    3108   snprint_time (buf, BUF_LEN
     3097  snprint_time (buf, sizeof (buf)
    31093098                frames_to_time (sample->sounddata->format, offset)); 
    31103099/* cheesy rate limiter. ugly in operation. limits pango damage */ 
     
    31163105  gtk_entry_set_text (GTK_ENTRY(view->play_pos), buf); 
    31173106#endif 
    3118  
    31193107} 
    31203108++rate_limit; 
    3121 #undef BUF_LEN 
    31223109 
    31233110  sample_display_refresh_play_marker (sd); 
     
    31683155view_set_progress_ready (sw_view * view) 
    31693156{ 
    3170 #define BUF_LEN 64 
    3171   static gchar buf[BUF_LEN]; 
     3157  gchar buf[64]; 
    31723158 
    31733159  if (view == NULL) return; 
    31743160 
    3175   snprintf (buf, BUF_LEN, "%s%s - %s", 
     3161  snprintf (buf, sizeof (buf), "%s%s - %s", 
    31763162            view->sample->modified ? "*" : "", 
    31773163            g_basename (view->sample->pathname), 
     
    31803166  gtk_progress_set_format_string (GTK_PROGRESS(view->progress), buf); 
    31813167  gtk_progress_set_percentage (GTK_PROGRESS(view->progress), 0.0); 
    3182 #undef BUF_LEN 
    31833168} 
    31843169 
     
    32163201{ 
    32173202  sw_sample * sample = view->sample; 
    3218 #define BUF_LEN 256 
    3219   char buf[BUF_LEN]; 
     3203  char buf[256]; 
    32203204 
    32213205  if (sample->modified && g_list_length (sample->views) == 1) { 
    3222     snprintf (buf, BUF_LEN, _("%s has been modified. Close anyway?"), 
     3206    snprintf (buf, sizeof (buf), _("%s has been modified. Close anyway?"), 
    32233207              g_basename (sample->pathname)); 
    32243208    question_dialog_new (sample, _("File modified"), buf, 
     
    32563240view_refresh_title (sw_view * view) 
    32573241{ 
     3242  char buf[256]; 
    32583243  sw_sample * s = (sw_sample *)view->sample; 
    32593244 
    3260 #define BUF_LEN 256 
    3261   char buf[BUF_LEN]; 
    3262  
    32633245  if (s->sounddata->nr_frames > 0) { 
    3264     snprintf(buf, BUF_LEN
     3246    snprintf(buf, sizeof (buf)
    32653247             "%s%s %0d%% - Sweep " VERSION, 
    32663248             s->modified ? _("*") : "", 
     
    32693251             s->progress_percent); 
    32703252  } else { 
    3271     snprintf(buf, BUF_LEN
     3253    snprintf(buf, sizeof (buf)
    32723254             "%s%s %s - Sweep " VERSION, 
    32733255             s->modified ? _("*") : "", 
     
    32773259 
    32783260  gtk_window_set_title (GTK_WINDOW(view->window), buf); 
    3279 #undef BUF_LEN 
    32803261} 
    32813262 
     
    32863267  sw_sounddata * sounddata = s->sounddata; 
    32873268 
    3288 #define BYTE_BUF_LEN 16 
    3289   char byte_buf[BYTE_BUF_LEN]; 
    3290  
    3291 #define TIME_BUF_LEN 16 
    3292   char time_buf[TIME_BUF_LEN]; 
    3293  
    3294 #define CHAN_BUF_LEN 16 
    3295   char chan_buf[CHAN_BUF_LEN]; 
    3296  
    3297 #define BUF_LEN 256 
    3298   char buf [BUF_LEN]; 
    3299  
    3300   snprint_bytes (byte_buf, BYTE_BUF_LEN, 
     3269  char byte_buf[16]; 
     3270  char time_buf[16]; 
     3271  char chan_buf[16]; 
     3272  char buf [256]; 
     3273 
     3274  snprint_bytes (byte_buf, sizeof (byte_buf), 
    33013275                 frames_to_bytes (sounddata->format, sounddata->nr_frames)); 
    33023276   
    3303   snprint_time (time_buf, TIME_BUF_LEN
     3277  snprint_time (time_buf, sizeof (time_buf)
    33043278                frames_to_time (sounddata->format, sounddata->nr_frames)); 
    33053279 
    33063280  switch (s->sounddata->format->channels) { 
    33073281  case 1: 
    3308     snprintf (chan_buf, CHAN_BUF_LEN, _("Mono")); 
     3282    snprintf (chan_buf, sizeof (chan_buf), _("Mono")); 
    33093283    break; 
    33103284  case 2: 
    3311     snprintf (chan_buf, CHAN_BUF_LEN, _("Stereo")); 
     3285    snprintf (chan_buf, sizeof (chan_buf), _("Stereo")); 
    33123286    break; 
    33133287  default: 
    3314     snprintf (chan_buf, CHAN_BUF_LEN, "%d %s", s->sounddata->format->channels, 
     3288    snprintf (chan_buf, sizeof (chan_buf), "%d %s", s->sounddata->format->channels, 
    33153289              _("channels")); 
    33163290    break; 
    33173291  } 
    33183292 
    3319   snprintf (buf, BUF_LEN
     3293  snprintf (buf, sizeof (buf)
    33203294            "%dHz %s [%s]", 
    33213295            s->sounddata->format->rate, 
     
    33233297 
    33243298  gtk_label_set_text (GTK_LABEL(view->status), buf); 
    3325  
    3326 #undef BUF_LEN 
    3327 #undef BYTE_BUF_LEN 
    3328 #undef TIME_BUF_LEN 
    33293299} 
    33303300