#include <libfirm/be.h>
#include <libfirm/statev.h>
+#include "adt/util.h"
#include "ast_t.h"
#include "preprocessor.h"
#include "token_t.h"
static char dep_target[4096];
if (outname != 0) {
size_t len = strlen(outname);
- if (len > sizeof(dep_target)-4) /* leave room for .d extension */
- len = sizeof(dep_target)-4;
+ len = MIN(len, sizeof(dep_target) - 4); /* leave room for .d extension */
memcpy(dep_target, outname, len);
/* replace extension with .d if found */
char *dot = &dep_target[len-1];
{
if (architecture_modulo_shift == 0)
return 0;
- if (type_size < architecture_modulo_shift)
- return architecture_modulo_shift;
- return type_size;
+ return MAX(type_size, architecture_modulo_shift);
}
static bool is_ia32_cpu(const char *architecture)
{
char buf[16384];
- while (!feof(input) && !ferror(dest)) {
+ for (;;) {
size_t read = fread(buf, 1, sizeof(buf), input);
+ if (read == 0)
+ break;
if (fwrite(buf, 1, read, dest) != read) {
perror("could not write output");
}